summaryrefslogtreecommitdiff
path: root/pkmem.h
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-01-06 15:19:21 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-01-06 15:19:21 -0500
commit3bd9d0d06f7d02c4f968e7679c80a2e53aa76afc (patch)
treeef2ae023d77c14ffb16a52ab805ffb45cd8df786 /pkmem.h
parentcb05cc6267cd6915d2b8f90f159adb1e09802e62 (diff)
pkmem: pk_bucket_head indexing + more mem tests
Diffstat (limited to 'pkmem.h')
-rw-r--r--pkmem.h10
1 files changed, 5 insertions, 5 deletions
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;
}