Commit f6366bc
committed
feat(foundation): add safe_free, safe_str_free, safe_buf_free, safe_grow memory helpers
Four new inline helpers in platform.h alongside existing safe_realloc:
- safe_free(ptr): frees and NULLs any pointer (prevents double-free)
- safe_str_free(&str): frees const char* and NULLs (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 realloc1 parent ac8fde6 commit f6366bc
1 file changed
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
34 | 76 | | |
35 | 77 | | |
36 | 78 | | |
| |||
0 commit comments