summaryrefslogtreecommitdiff
path: root/test/pkmem.c
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-06-05 00:51:35 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-06-05 09:59:02 -0400
commit053b5ab41a7747f83b25906ea46446eba8c6ea9a (patch)
treed244e72365d1c222182dad6d8f21c68d6ef89536 /test/pkmem.c
parent54c3fbaaf3e10c4b9aa15f3d32864b0ebfc06eee (diff)
pkmem: handle accessing uninitialized debug blocks
Diffstat (limited to 'test/pkmem.c')
-rw-r--r--test/pkmem.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/pkmem.c b/test/pkmem.c
index ad95899..36bf0eb 100644
--- a/test/pkmem.c
+++ b/test/pkmem.c
@@ -113,5 +113,72 @@ int main(int argc, char *argv[])
teardown();
}
+ // expand buckets
+ {
+ // spinup_w_instr();
+ spinup();
+
+ /*
+ * [00-47] (48) ptr1
+ * [48-XX] ( 1) HEAD
+ */
+ void *ptr1 = pk_new_bkt(48, 1, mt.bkt1);
+ (void)ptr1;
+
+ if ((void*)&mt.bkt1->data[0] != ptr1) exit(1);
+ if (mt.bkt1->alloc_count != 1) exit(1);
+ if (mt.bkt1->head != 48) exit(1);
+ if (mt.bkt1->debug_head_l != 1) exit(1);
+ if (mt.bkt1->debug_head_r != 1) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ /*
+ * [00-47] (48) ptr1
+ * [ 48] ( 1) ptr2
+ * [49-XX] ( 1) HEAD
+ */
+ void *ptr2 = pk_new_bkt(1, 1, mt.bkt1);
+
+ if ((void*)(&mt.bkt1->data[0]+48) != ptr2) exit(1);
+ if (mt.bkt1->alloc_count != 2) exit(1);
+ if (mt.bkt1->head != 49) exit(1);
+ if (mt.bkt1->debug_head_l != 2) exit(1);
+ if (mt.bkt1->debug_head_r != 2) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ /*
+ * [00-47] (48) ptr1
+ * [48-XX] ( 1) HEAD
+ */
+ pk_delete_bkt(ptr2, 1, mt.bkt1);
+
+ if (mt.bkt1->alloc_count != 1) exit(1);
+ if (mt.bkt1->head != 48) exit(1);
+ if (mt.bkt1->debug_head_l != 1) exit(1);
+ if (mt.bkt1->debug_head_r != 2) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ /*
+ * [00-47] (48) ptr1
+ * [ 48] ( 1) ptr2
+ * [49-XX] ( 1) HEAD
+ */
+ ptr2 = pk_new_bkt(1, 1, mt.bkt1);
+
+ if ((void*)(&mt.bkt1->data[0]+48) != ptr2) exit(1);
+ if (mt.bkt1->alloc_count != 2) exit(1);
+ if (mt.bkt1->head != 49) exit(1);
+ if (mt.bkt1->debug_head_l != 2) exit(1);
+ if (mt.bkt1->debug_head_r != 2) exit(1);
+ if (mt.bkt1->block_head_l != 0) exit(1);
+ if (mt.bkt1->block_head_r != 0) exit(1);
+
+ PK_LOGV_INF("%s: %s\n", __FILE__, "handles free last + new");
+ teardown();
+ }
+
return 0;
}