:: Re: [DNG] Pointer error in the back…
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Rainer Weikusat
Date:  
À: dng
Sujet: Re: [DNG] Pointer error in the backend of Netman
Edward Bartolo <edbarx@???> writes:

[...]

> Realloc uses two parameters: the first is a pointer whose allocation
> is to be modified/reallocated. The second is the NEW number of bytes
> required. In the function line 240 is:
> active_wifi_list = realloc(active_wifi_list, (((z - 1)/2) +
> list_delta)*sizeof(void*));
>
> I should assume that the assignment is unnecessary although it works.


The assignment is not uneccesary: On success, realloc returns a pointer
to the new area and the old pointer becomes invalid. If the allocation
can be extended in place, realloc may just return the old pointer,
however, if it can't, it will return a pointer to some newly-allocated
storage and the old will be freed.