Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #60066

Re: Malloc without free in linked list code

From Richard Heathfield <rjh@cpax.org.uk>
Newsgroups comp.lang.c
Subject Re: Malloc without free in linked list code
Date 2015-04-15 00:20 +0100
Organization go, ion artisan!
Message-ID <mgk79o$kdr$1@dont-email.me> (permalink)
References (6 earlier) <mgj3id$62k$1@dont-email.me> <87d236kap2.fsf@bsb.me.uk> <mgjc5h$7u9$1@dont-email.me> <mgjop3$r7p$1@dont-email.me> <mgk2r0$75h$1@dont-email.me>

Show all headers | View raw


On 14/04/15 23:04, David Brown wrote:
> On 14/04/15 21:12, Richard Heathfield wrote:
>> On 14/04/15 16:37, David Brown wrote:
>>
>> <snip>
>>>
>>> Yes.  I was just acknowledging that.  (Similarly, I believe I had an
>>> "IMHO" somewhere when saying I don't like double pointers.)
>>
>> How do you feel about unsigned long pointers?
>>
>> I have no objection whatsoever to T**, but I do object to the misleading
>> term "double pointer".
>>
>
> (I should have read this before replying to Keith's post.)
>
> Okay - I don't see anything misleading about the term "double pointer",
> but if other people do, I'll try to remember to avoid it.

The phrase *always* gives me pause, because I am aware that some people 
use it in one sense and others in another.

> I have nothing against a pointer to an unsigned long

The question, of course, was designed to draw your attention to the 
ambiguity of 'double pointer'.


> (though usually I
> prefer sized types for the type of code I write - and thus uint32_t*
> would be much more likely in my programming).  I just think pointers to
> pointers can add complexity and should be avoided unless they are
> particularly useful (and in this case, they are unnecessary).

I see no particular reason to avoid them. (Nor do I see any reason to 
use them when their use is not - uh - useful.)

fclose would have benefited from taking FILE **, and being implemented 
along these lines:

int fclose(FILE **fp)
{
   int rc = !fp ? EOF : !*fp ? EOF : __fcloseinternal(*fp);
   if(fp) { *fp = NULL; }
   return rc;
}

This is where I habitually use T** - to allow a function to mark a 
resource as unavailable immediately after releasing it.

T** has other uses, of course, but for this use alone it is worth 
conquering any innate antipathy towards it.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Malloc without free in linked list code Paul <pepstein5@gmail.com> - 2015-04-13 11:21 -0700
  Re: Malloc without free in linked list code Lőrinczy Zsigmond <nospam@for.me> - 2015-04-13 20:45 +0200
  Re: Malloc without free in linked list code Richard Heathfield <rjh@cpax.org.uk> - 2015-04-13 19:53 +0100
  Malloc without free in linked list code asetofsymbols@gmail.com - 2015-04-13 12:05 -0700
  Re: Malloc without free in linked list code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-13 21:58 +0100
    Re: Malloc without free in linked list code David Brown <david.brown@hesbynett.no> - 2015-04-14 09:26 +0200
      Re: Malloc without free in linked list code Paul <pepstein5@gmail.com> - 2015-04-14 01:45 -0700
        Re: Malloc without free in linked list code David Brown <david.brown@hesbynett.no> - 2015-04-14 11:39 +0200
          Re: Malloc without free in linked list code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-14 13:43 +0100
            Re: Malloc without free in linked list code David Brown <david.brown@hesbynett.no> - 2015-04-14 15:10 +0200
              Re: Malloc without free in linked list code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-14 16:10 +0100
                Re: Malloc without free in linked list code David Brown <david.brown@hesbynett.no> - 2015-04-14 17:37 +0200
                Re: Malloc without free in linked list code Keith Thompson <kst-u@mib.org> - 2015-04-14 11:44 -0700
                Re: Malloc without free in linked list code David Brown <david.brown@hesbynett.no> - 2015-04-15 00:00 +0200
                Re: Malloc without free in linked list code Richard Heathfield <rjh@cpax.org.uk> - 2015-04-14 20:12 +0100
                Re: Malloc without free in linked list code David Brown <david.brown@hesbynett.no> - 2015-04-15 00:04 +0200
                Re: Malloc without free in linked list code Richard Heathfield <rjh@cpax.org.uk> - 2015-04-15 00:20 +0100
              Re: Malloc without free in linked list code Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-16 15:46 -0700
                Re: Malloc without free in linked list code David Brown <david.brown@hesbynett.no> - 2015-04-17 10:38 +0200
                Re: Malloc without free in linked list code Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-17 08:30 -0700
        Re: Malloc without free in linked list code James Kuyper <jameskuyper@verizon.net> - 2015-04-14 08:04 -0400
  Re: Malloc without free in linked list code Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-14 05:38 -0700
  Re: Malloc without free in linked list code BGB <cr88192@hotmail.com> - 2015-04-14 10:31 -0500
  Malloc without free in linked list code Chad <cdalten@gmail.com> - 2015-04-14 19:51 -0700
    Re: Malloc without free in linked list code James Kuyper <jameskuyper@verizon.net> - 2015-04-14 23:10 -0400

csiph-web