22 Commits

Author SHA1 Message Date
Aryadev Chavali
324b1d2dd5 prick_btree: rearrange prick_bnode_print function arguments 2025-11-25 19:14:46 +00:00
Aryadev Chavali
9b7a5af6ec prick_btree: Add assertion to ensure all management functions aren't NULL 2025-11-25 19:08:00 +00:00
Aryadev Chavali
8783361010 prick_btree: add custom printing function for values
Something you can feed in to the init function to be used by the
printer functions.
2025-11-25 19:07:23 +00:00
Aryadev Chavali
0278ee8599 gitignore 2025-11-25 18:50:45 +00:00
Aryadev Chavali
d3c284f762 prick_btree: refactor for namespacing
everything should have a `prick_` prepended name.  Just makes sense.
2025-11-25 18:50:22 +00:00
Aryadev Chavali
3ca2f3fb2a prick_btree: provide a general btree_t structure
This structure stores our comparator and allocator functions, as well
as a root node, ensuring we're using the same functions on one tree.
Makes the API much cleaner to use.
2025-11-17 01:05:09 +00:00
Aryadev Chavali
6d91af65aa prick_btree
Still need to make it better imo
2025-11-17 00:56:28 +00:00
Aryadev Chavali
cb583d0277 types -> prick_aliases 2025-11-17 00:56:19 +00:00
Aryadev Chavali
50bd444d7e arena -> prick_arena 2025-11-17 00:56:19 +00:00
Aryadev Chavali
f4364f38d1 vec -> prick_darr.h 2025-11-17 00:56:19 +00:00
Aryadev Chavali
44d97efd54 Added README 2025-11-17 00:18:17 +00:00
Aryadev Chavali
c93d358b6a Add types.h for useful type aliases
So simple it's not got any functions.
2025-04-09 22:55:37 +01:00
Aryadev Chavali
4218fa3a2c Translate region_delete_rec while loop to for loop, minor edits 2025-04-09 22:52:58 +01:00
Aryadev Chavali
1dd0f8835c Fixed arena_realloc
So the real purpose of arena_realloc is to figure out if we can get
away with just adjusting the region that the pointer given resides in
so that we don't need to _actually_ allocate any new memory.

The previous implementation did this in the special case where the
pointer given _is_ the entire region.  But we can adjust the region's
size _if_ the pointer given is the last allocation on the region
i.e. it's on the tail end.
2025-04-09 22:49:21 +01:00
Aryadev Chavali
1b78493b19 Completely document arena's functions and make region public
If someone uses the arena functionality, they may as well get the
region functionality for free.  In particular, they may just want a
fixed bump allocator implementation which they can get here for free.
2024-11-01 08:16:03 +00:00
Aryadev Chavali
9427c3d324 Implement arena_reset 2024-11-01 08:15:46 +00:00
Aryadev Chavali
cf93eede6b region_delete->region_delete_rec and slightly rework arena_realloc
1) Better naming.

2) Use MIN macro for choosing the size to copy over from the old
buffer to the new one.  Also fix issue where we free the old region of
memory before copying it over to the new buffer.
2024-11-01 08:13:11 +00:00
Aryadev Chavali
46f62c5d2c Simple arena implementation using singly linked list
Manages individual allocations via a bump allocator (region), with
unfit allocations triggering a new region allocation that is added to
a linked list.  Any new region allocations will always be oversized
for the initially requested size, to amortize the cost of future
allocations.
2024-11-01 07:48:19 +00:00
Aryadev Chavali
f0f1e06e1e VEC_MULT may be set as user, so have a #if guard. 2024-10-24 03:17:54 +01:00
Aryadev Chavali
3a8f0c8d00 Use VEC_MULT in vec_ensure_remaining 2024-10-24 03:13:14 +01:00
Aryadev Chavali
14dea7c48c Clean up macros in vec.h 2024-10-24 03:13:03 +01:00
Aryadev Chavali
6ca508851a Vector library 2024-10-01 05:21:59 +01:00