MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / safe_free_impl

Function safe_free_impl

src/foundation/platform.h:36–41  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

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. */
36static 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.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected