Hi
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.
I suppose it forces the developer to be careful with memory management - is this the only reason?
Regards Richard.
This email is subject to the disclaimer of Smile Communications (PTY) Ltd. at http://www.smilecoms.com/disclaimer
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