Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: C
Posted by: Jose Fernando Lopez Fernandez
Added: May 18, 2018 12:00 AM
Views: 14
Tags: no tags
Prevents freeing a memory address twice
  1. void SafeFree(void **ptrRef) {
  2.     if (*ptrRef == NULL)
  3.         return;
  4.  
  5.     free(*ptrRef);
  6.     *ptrRef = NULL;
  7. }