You are right for the upstream behavior. The version that we have in the
cumulus tree is this:
106 void *
107 zrealloc (int type, void *ptr, size_t size)
108 {
109 void *memory;
110
111 memory = realloc (ptr, size);
112 if (memory == NULL)
113 zerror ("realloc", type, size);
114 if (ptr == NULL)
115 alloc_inc (type);
116
117 return memory;
118 }
Which would not work too well with your patch :)
ah well. My mistake.
acked-by: Donald Sharp <[email protected]>
donald
On Tue, May 3, 2016 at 1:26 PM, Christian Franke <
[email protected]> wrote:
> On 05/03/2016 07:05 PM, Donald Sharp wrote:
> > If you pass in a NULL ptr, but with a size, it acts as a malloc. From
> > the man page:
> >
> > If ptr is NULL, then the call is equivalent to
> > malloc(size), for all values of size; if size is equal to zero,
> > and ptr is not NULL, then the call is equivalent to
> > free(ptr).
> >
> > Not a good patch imo.
>
> The whole zrealloc function with the patch looks like this (let's hope
> Thunderbird doesn't screw it up too badly):
>
> void *
> zrealloc (int type, void *ptr, size_t size)
> {
> void *memory;
>
> if (ptr == NULL) /* is really alloc */
> return zcalloc(type, size);
>
> memory = realloc (ptr, size);
> if (memory == NULL)
> zerror ("realloc", type, size);
>
> - if (ptr == NULL)
> - alloc_inc (type);
>
> return memory;
> }
>
> So if NULL is passed in as ptr to zrealloc, it will return the result of
> zcalloc. The code that I remove in the patch will never be called.
>
> -Christian
>
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev