Commit graph

21 commits

Author SHA1 Message Date
Andrei Alexeyev
787773a53b
memory/arena: add snapshot and rollback APIs 2024-09-10 14:31:55 +02:00
Andrei Alexeyev
5e0d85af1b
memory/arena: add opportunistic free and realloc functions 2024-09-10 14:31:55 +02:00
Andrei Alexeyev
1fc752531a
memory/arena: fix alignment offset calculation
Previously would add an unnecessary padding equal to alignment if the
pointer is already sufficiently aligned
2024-09-10 14:31:55 +02:00
Andrei Alexeyev
1ca51a6690
memory/arena: fix page size calculation 2024-09-10 14:31:55 +02:00
Andrei Alexeyev
fda8556a39
src: deprecate strdup(), use mem_strdup() explicitly
This fixes a nasty bug that manifests on windows when building without
precompiled headers. util/stringops.h used to silently replace strdup
with a macro that's compatible with mem_free(). This header would
typically be included everywhere due to PCH, but without it the strdup
from libc would sometimes be in scope. On most platforms mem_free() is
equivalent to free(), but not on windows, because we have to use
_aligned_free() there. Attempting to mem_free() the result of a libc
strdup() would segfault in such a configuration.

Avoid the footgun by banning strdup() entirely. Maybe redefining libc
names isn't such a great idea, who knew?
2024-09-10 14:31:55 +02:00
Andrei Alexeyev
c8a2fb1418
memory: fix mem_realloc edge case on windows 2024-09-10 14:28:36 +02:00
Andrei Alexeyev
d676808ad1
memory/arena: add ARENA_ALLOC series of macros 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
a15b193c0b
memory/arena: add marena_memdup() and marena_strdup() 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
1f05199456
memory/arena: add marena_alloc_array_aligned() 2024-08-30 11:52:47 +02:00
Andrei Alexeyev
3dc8624265
memory/mempool: fix warning 2024-06-15 09:31:14 +02:00
Andrei Alexeyev
f9c2748fae
memory/mempool: pass arena pointer to acquire() instead of storing in struct 2024-06-05 22:07:17 +02:00
Andrei Alexeyev
13ace0e5c0
memory/mempool: refactor to avoid storing object size and alignment in struct
Works similarly to DYNAMMIC_ARRAY(type)
2024-06-05 21:16:02 +02:00
Andrei Alexeyev
05168ac2d7
memory/mempool: rename from objectpool 2024-06-05 18:35:08 +02:00
Andrei Alexeyev
8b37d1cbf2
src: the great #include massacre of 2024 2024-05-17 14:11:48 +02:00
Andrei Alexeyev
be7905d6a3
src: run upkeep 2024-05-17 04:58:47 +02:00
Andrei Alexeyev
76886a3f44
src/memory: remove irrelevant #include 2024-05-16 22:24:18 +02:00
Andrei Alexeyev
8f8ca2beca
all: use min/max macros; avoid some unnecessary conversions 2023-09-28 17:43:14 +02:00
Andrei Alexeyev
9089a2f16e
memory/allocator: add ALLOC_VIA macros 2023-04-03 01:53:36 +02:00
Andrei Alexeyev
e555126854
memory: generic allocator interface 2023-04-03 01:53:36 +02:00
Andrei Alexeyev
8547f443b7
memory: basic arena allocator primitive 2023-04-03 01:53:36 +02:00
Andrei Alexeyev
bf7964926c
memory: move into subdir 2023-04-03 01:53:36 +02:00