Safe free: frees and NULLs a pointer to prevent double-free / use-after-free. * Use via the safe_free() macro so the caller's pointer is actually cleared. */
| 34 | /* Safe free: frees and NULLs a pointer to prevent double-free / use-after-free. |
| 35 | * Use via the safe_free() macro so the caller's pointer is actually cleared. */ |
| 36 | static inline void safe_free_impl(void **pp) { |
| 37 | if (pp && *pp) { |
| 38 | free(*pp); |
| 39 | *pp = NULL; |
| 40 | } |
| 41 | } |
| 42 | #define safe_free(ptr) safe_free_impl((void **)(void *)&(ptr)) |
| 43 | |
| 44 | /* Safe const string free: frees a const char* and NULLs it. |
nothing calls this directly
no outgoing calls
no test coverage detected