Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: double free Date: Sat, 09 Jul 2016 13:28:52 -0700 Organization: None to speak of Lines: 24 Message-ID: References: <577ba42f.13700328@news.xs4all.nl> <48c43c3f-8e7e-0509-5b9d-04133e7bb537@verizon.net> <16f5cce4-d88e-48e8-a141-9f5b604adcaf@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="3862"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jvDv+cOB6uo5HJp/Zhj2V" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:jTlGOTROGGQNkYuFi7UJz2Dw+Ok= sha1:EyP29eCHnPnjVHBX/AKPy8iV2F8= Xref: csiph.com comp.lang.c:90156 Malcolm McLean writes: > On Saturday, July 9, 2016 at 3:16:09 PM UTC+1, James R. Kuyper wrote: >> True - but the case under discussion is one of those reasons. In pure >> C++ code, calls to malloc() should almost always be replaced by more >> type-safe approaches such as direct or indirect use of the 'new' >> operator. But in code meant to be usable in both C and C++, it's >> annoying that casting the value returned by malloc() is mandatory in >> C++, and a bad idea in C. >> > It's not really "a bad idea" in C. Yes, it really is. > comp.lang.c is hardly the authority on good C style. Nobody claimed it was. The reasons that casting the result of malloc() in C is a bad idea are valid on their own, without regard to whether they've been discussed in this newsgroup or not. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"