From 62b4a3ededd237f4b4850d91c052585e2f687499 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 2 Jun 2024 21:46:07 +1000 Subject: Switched to luigi, parsing out FLAC metadata. --- memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index 9dd99c2..f35ed51 100644 --- a/memory.c +++ b/memory.c @@ -75,7 +75,6 @@ static void* heap_alloc_impla(Heap* h, int size) { as = size + sizeof *header; p = 0; m = sizeof *header; - h->usage += as; for (i = 0; i < h->blocks; i++) { header = (int*)(h->buffer + p); s = header[0]; @@ -87,9 +86,11 @@ static void* heap_alloc_impla(Heap* h, int size) { header[0] = (s << 1); nh = (int*)(h->buffer + p + s); nh[0] = (as << 1) | 1; + h->usage += as; h->blocks++; return nh + 1; } else if (s == as) { + h->usage += as; header[0] |= 1; return header + 1; } @@ -203,6 +204,11 @@ void heap_free(Heap* h, void* ptr) { heap_free_aligned(h, ptr); } +int heap_block_size(void* ptr) { + int h = ((int*)ptr)[-1]; + return h >> 1; +} + void* galloc(int size) { #if use_system_malloc return malloc(size); -- cgit v1.2.3-54-g00ecf