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

Function safe_buf_free_impl

src/foundation/platform.h:55–63  ·  view source on GitHub ↗

Safe buffer free: frees a heap array and zeros its element count. * Use for dynamic arrays paired with a size_t count. */

Source from the content-addressed store, hash-verified

53/* Safe buffer free: frees a heap array and zeros its element count.
54 * Use for dynamic arrays paired with a size_t count. */
55static inline void safe_buf_free_impl(void **buf, size_t *count) {
56 if (buf && *buf) {
57 free(*buf);
58 *buf = NULL;
59 }
60 if (count) {
61 *count = 0;
62 }
63}
64#define safe_buf_free(buf, countp) safe_buf_free_impl((void **)(void *)&(buf), (countp))
65
66/* Safe grow: doubles capacity and reallocs when count reaches cap.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected