[sr-dev] Does shm_free() make the pointer NULL?
Iñaki Baz Castillo
ibc at aliax.net
Tue Feb 28 20:23:47 CET 2012
2012/2/28 Daniel-Constantin Mierla <miconda at gmail.com>:
> the pointer is not set to NULL, it never was, no matter the version and
> name, since ser was started. Not even with system malloc, free does not set
> it to null. One reason is that the pointer is given as parameter by value,
> so the variable holding it cannot be changed. Well, in K, shm_free() is a
> macro (define) and can be coded to set it to null, but it is a risk if the
> parameter is an expression (e.g., computing the pointer from: a start of a
> structure + offset).
>
> To be able and safe to set it to null in a function, the parameter must be a
> pointer to the pointer, like:
>
>
> static int *number;
> number = shm_malloc(sizeof(int));
> my_shm_free(&number);
Thanks a lot. Then there was a bug I will fix right now. Indeed
setting it to NULL does fix the problem.
--
Iñaki Baz Castillo
<ibc at aliax.net>
More information about the sr-dev
mailing list