[sr-dev] shm_free - not setting pointer to zero?

Juha Heinanen jh at tutpro.com
Mon May 28 09:32:16 CEST 2012


Richard Good writes:

> Is there any reason why shm_free does not set the pointer it is freeing to
> zero once it is free-ed?
> 
> Code like:
> *if (pointer) {
>             shm_free(pointer);*
> 
> Is not really useful seen as how shm_free does not set the pointer to zero
> - any double free will still cause a crash.

if shm_free would set the pointer to zero, then you would need to pass
pointer's address as argument.

it is not really a problem.  you just set the pointer to zero after
calling shm_free, for example:

    if (rule_pt) {
	shm_free(rule_pt);
	rule_pt = 0;
    }

-- juha



More information about the sr-dev mailing list