Realloc in asn1.c

Nigel Williams nigel at wednesday.demon.co.uk
Sun Oct 14 10:10:02 GMT 2001


There has been so much effort made recently to fix these occurrences and
this was code was only a couple of days old.

as

p = Realloc(p, size);

seems to be a natural way to use Realloc. Would it be a good idea to create
a couple of new functions say

Reallocf()

which performs a free internally before returning NULL

and

Reallocfmc()

which performs a free, malloc, copy internally (I've had to do this with NT
in the past. realloc failed quite often on NT where malloc did not.)

These functions could be used in new code wherever there is only one
reference to the memory being resized and save effort in the future.

> -----Original Message-----
> From: Andrew Tridgell [mailto:tridge at samba.org]
> Sent: 14 October 2001 02:21
> To: nigel at wednesday.demon.co.uk
> Cc: samba-technical at lists.samba.org
> Subject: Re: Realloc in asn1.c
>
>
> > I just noticed this while browsing the code.  Memory leaks seem
> to be a hot
> > topic at the moment.  Apologies if I am wrong.
>
> I'll fix this for the sake of completeness, but please remember that
> it is not allocation failures that cause memory leaks. Allocation
> failures are *extremely* rare on unix systems. So rare that making an
> allocation failure cause a exit(1) would not be completely
> unreasonable.
>





More information about the samba-technical mailing list