Commit 348f890
committed
refactor(memory): add safe_free, safe_str_free, safe_buf_free, safe_grow to platform.h
Centralize heap memory management into four safe wrappers alongside
existing safe_realloc:
- safe_free(ptr): frees and NULLs any pointer to prevent double-free
- safe_str_free(&str): frees const char* with NULL-out (replaces free((void*)str))
- safe_buf_free(buf, &count): frees array and zeros its count
- safe_grow(arr, n, cap, factor): one-line capacity-doubling realloc
Applied across cypher.c, store.c, mcp.c, and pass_githistory.c,
eliminating ~60 lines of repetitive free/grow boilerplate.1 parent 1d30971 commit 348f890
5 files changed
Lines changed: 364 additions & 424 deletions
0 commit comments