Commit a022723
committed
fix(state): add memory cleanup for allocated State fields
- Add deinit() method to State struct to free session_id and last_update
- Call st.deinit() in main.zig before program exit
- Fixes memory leak when State is loaded from JSON file
The State.load() function allocates memory for session_id and last_update
using allocator.dupe(), but this memory was never freed. This commit adds
proper cleanup to prevent memory leaks.
Signed-off-by: leocavalcante <[email protected]>1 parent b9b040e commit a022723
2 files changed
+13
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
0 commit comments