diff options
| author | WormHeamer | 2026-01-01 18:03:53 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-01 18:03:53 -0500 |
| commit | 15647d632973d8aafa163f2e19af11b999195853 (patch) | |
| tree | 09ec7667798d714dccbbd0cd529bdac6dd6320dd | |
| parent | 4018b4f3b06ea31a19239118085d049f319df128 (diff) | |
fix bug in arena_realloc()
i don't remember what it was but it broke select_file_in()
| -rw-r--r-- | arena.h | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -77,9 +77,14 @@ void *arena_alloc(Arena *a, size_t sz, size_t align) { } void *arena_realloc(Arena *a, void *old, size_t oldsz, size_t newsz, size_t align) { - if (old == a->beg - oldsz) a->beg = old; - else if (old) memcpy(a->beg, old, oldsz); - return arena_alloc(a, newsz, align); + if (old == a->beg - oldsz) { + a->beg = (char*)old + newsz; + return old; + } else { + void *p = arena_alloc(a, newsz, align); + if (old) memcpy(p, old, oldsz); + return p; + } } #endif |
