summaryrefslogtreecommitdiff
path: root/blockarr.c
diff options
context:
space:
mode:
Diffstat (limited to 'blockarr.c')
-rw-r--r--blockarr.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/blockarr.c b/blockarr.c
index 16ab041..cc06774 100644
--- a/blockarr.c
+++ b/blockarr.c
@@ -16,7 +16,7 @@ static void block_arr_create(BlockArr *arr, int lg_block_sz, size_t item_sz) {
static void *block_arr_add(BlockArr *arr) {
ArrBlock *last_block;
- last_block = arr_last(&arr->blocks);
+ last_block = arr_last(arr->blocks);
if (arr->blocks == NULL ||
(unsigned long)last_block->n >= (1UL << arr->lg_block_sz)) {
ArrBlock *block;
@@ -46,3 +46,18 @@ static void block_arr_free(BlockArr *arr) {
}
arr_clear(&arr->blocks);
}
+
+static void block_arr_test(void) {
+ BlockArr a;
+ int *ps[100];
+ block_arr_create(&a, 3, sizeof(int));
+ for (int i = 0; i < 100; i++) {
+ int *p = block_arr_add(&a);
+ *p = i;
+ ps[i] = p;
+ }
+ for (int i = 0; i < 100; i++) {
+ assert(*ps[i] == i);
+ }
+ block_arr_free(&a);
+}