aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-05-30 08:15:29 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-05-30 08:15:29 +0100
commit70aa166624a5377c8dd60854cea967325af8c21b (patch)
tree4ec6497fc5c557cb4266f23627c92a1fb069f613 /lib
parent4dc3d8f8325994d737f1959c1554480f4ccbc60f (diff)
downloadoats-70aa166624a5377c8dd60854cea967325af8c21b.tar.gz
oats-70aa166624a5377c8dd60854cea967325af8c21b.tar.bz2
oats-70aa166624a5377c8dd60854cea967325af8c21b.zip
Clean up
Diffstat (limited to 'lib')
-rw-r--r--lib/arena.c6
-rw-r--r--lib/sv.h1
2 files changed, 3 insertions, 4 deletions
diff --git a/lib/arena.c b/lib/arena.c
index aa2d775..f3f254d 100644
--- a/lib/arena.c
+++ b/lib/arena.c
@@ -114,7 +114,7 @@ void *arena_realloc(arena_t *arena, void *ptr, u64 oldsize, u64 newsize)
// No need to change anything.
return ptr;
- bool copy_into_new = true;
+ bool copy_into_new = false;
void *start = NULL;
page_t *old_page = NULL, *best_fit = NULL;
@@ -134,12 +134,9 @@ void *arena_realloc(arena_t *arena, void *ptr, u64 oldsize, u64 newsize)
{
start = ptr;
old_page->size += newsize - oldsize;
- copy_into_new = false;
}
else
{
- if (!old_page)
- copy_into_new = false;
if (!best_fit)
{
best_fit = page_create(newsize);
@@ -149,6 +146,7 @@ void *arena_realloc(arena_t *arena, void *ptr, u64 oldsize, u64 newsize)
start = best_fit->data + best_fit->size;
best_fit->size += newsize;
+ copy_into_new = true;
}
if (copy_into_new)
diff --git a/lib/sv.h b/lib/sv.h
index 3293b1c..4e600c2 100644
--- a/lib/sv.h
+++ b/lib/sv.h
@@ -27,6 +27,7 @@ typedef struct SV
#define SV(DATA, SIZE) ((const sv_t){.size = (SIZE), .data = (DATA)})
#define SV_FMT(SV) (int)(SV).size, (SV).data
#define PR_SV "%.*s"
+#define PR_DEBUG_SV "%d@%p"
sv_t sv_make(arena_t *allocator, const char *data, u64 size);
sv_t sv_copy(arena_t *allocator, sv_t sv);