From 3bd9d0d06f7d02c4f968e7679c80a2e53aa76afc Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 6 Jan 2025 15:19:21 -0500 Subject: pkmem: pk_bucket_head indexing + more mem tests --- pkmem.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pkmem.h') diff --git a/pkmem.h b/pkmem.h index 1542188..88261f9 100644 --- a/pkmem.h +++ b/pkmem.h @@ -210,13 +210,12 @@ pk_memory_debug_print() void pk_memory_flush() { - for (long i = pk_bucket_head - 2; i > -1; --i) { + for (long i = pk_bucket_head - 1; i > -1; --i) { if (pk_buckets[i].head != 0) break; - if (pk_buckets[i+1].head != 0) break; if (pk_buckets[i].transient == true) break; - if (pk_buckets[i+1].transient == true) break; pk_bucket_head--; - pk_bucket_destroy(&pk_buckets[i + 1]); + if (pk_buckets[i].raw == CAFE_BABE(void)) continue; + pk_bucket_destroy(&pk_buckets[i]); } } @@ -225,6 +224,7 @@ pk_memory_teardown_all() { for (int64_t i = pk_bucket_head; i > 0; --i) { if (pk_buckets[i - 1].ptr == nullptr) continue; + if (pk_buckets[i - 1].ptr == CAFE_BABE(char)) continue; pk_bucket_destroy(&pk_buckets[i - 1]); } pk_bucket_head = 0; @@ -281,7 +281,7 @@ pk_bucket_destroy(struct pk_membucket* bkt) int64_t i; for (i = 0; i < pk_bucket_head; ++i) { if (&pk_buckets[i] == bkt) { - if (pk_bucket_head == i) + if (pk_bucket_head == i + 1) pk_bucket_head--; break; } -- cgit v1.2.3