From c8e0e51b8dc67e1310fab793d5d02fe33a4a660b Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Wed, 15 May 2024 13:56:08 -0400 Subject: [PATCH] working --- Makefile | 8 ++++---- src/sparsemap.c | 10 ---------- tests/test.c | 3 +++ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 1f7f43e..1eb2aa4 100644 --- a/Makefile +++ b/Makefile @@ -6,15 +6,15 @@ SHARED_LIB = libsparsemap.so LIBS = -lm #CFLAGS = -Wall -Wextra -Wpedantic -Of -std=c11 -Iinclude/ -fPIC #CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC -CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -fPIC -#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -fPIC +#CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -fPIC +CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -fPIC #CFLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -fPIC #CFLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -fPIC #CFLAGS = -DSPARSEMAP_DIAGNOSTIC -DDEBUG -Wall -Wextra -Wpedantic -Og -g -fsanitize=address,leak,object-size,pointer-compare,pointer-subtract,null,return,bounds,pointer-overflow,undefined -fsanitize-address-use-after-scope -std=c11 -Iinclude/ -fPIC #CFLAGS = -Wall -Wextra -Wpedantic -Og -g -fsanitize=all -fhardened -std=c11 -Iinclude/ -fPIC -TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -Itests/ -fPIC -#TEST_FLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -Itests/ -fPIC +#TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -O0 -g -std=c11 -Iinclude/ -Itests/ -fPIC +TEST_FLAGS = -Wall -Wextra -Wpedantic -Ofast -g -std=c11 -Iinclude/ -Itests/ -fPIC #TEST_FLAGS = -Wall -Wextra -Wpedantic -Og -g -std=c11 -Iinclude/ -Itests/ -fPIC #TEST_FLAGS = -DDEBUG -Wall -Wextra -Wpedantic -Og -g -fsanitize=address,leak,object-size,pointer-compare,pointer-subtract,null,return,bounds,pointer-overflow,undefined -fsanitize-address-use-after-scope -std=c11 -Iinclude/ -fPIC diff --git a/src/sparsemap.c b/src/sparsemap.c index 0df933d..ac11708 100644 --- a/src/sparsemap.c +++ b/src/sparsemap.c @@ -1431,8 +1431,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) { uint8_t *src, *dst; size_t src_count = __sm_get_chunk_count(source); - sparsemap_idx_t src_starting_offset = sparsemap_get_starting_offset(source); - sparsemap_idx_t src_ending_offset = sparsemap_get_ending_offset(source); sparsemap_idx_t dst_ending_offset = sparsemap_get_ending_offset(destination); if (src_count == 0) { @@ -1448,8 +1446,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) return -remaining_capacity; } - size_t i = src_starting_offset; - size_t merge_end_offset = __sm_get_chunk_aligned_offset(src_ending_offset) + SM_CHUNK_MAX_CAPACITY; src = __sm_get_chunk_data(source, 0); while (src_count) { sm_idx_t src_start = *(sm_idx_t *)src; @@ -1482,7 +1478,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) __sm_insert_data(destination, offset, src, sizeof(sm_idx_t) + src_size); /* Update the chunk count and data_used. */ __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); - i += src_capacity; src_count--; src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); continue; @@ -1499,7 +1494,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) } /* Update the chunk count and data_used. */ __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); - i += src_capacity; src_count--; src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); continue; @@ -1508,7 +1502,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) /* Source and destination and a perfect overlapping pair. */ if (src_start == dst_start && src_capacity == dst_capacity) { __sm_merge_chunk(destination, src_start, dst_start, dst_capacity, &dst_chunk, &src_chunk); - i += src_capacity; src_count--; src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); continue; @@ -1525,7 +1518,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) sparsemap_set(destination, n, true); } } - i += src_capacity; src_count--; src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); continue; @@ -1539,7 +1531,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) /* Update the chunk count and data_used. */ __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); - i += src_capacity; src_count--; src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); continue; @@ -1552,7 +1543,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source) /* Update the chunk count and data_used. */ __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); - i += src_capacity; src_count--; src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); continue; diff --git a/tests/test.c b/tests/test.c index 34e37ab..87c7c06 100644 --- a/tests/test.c +++ b/tests/test.c @@ -543,6 +543,9 @@ test_api_get_data(const MunitParameter params[], void *data) assert_true(sparsemap_get_data(map) == buf); + munit_free(buf); + munit_free(map); + return MUNIT_OK; }