This commit is contained in:
Gregory Burd 2024-05-15 13:56:08 -04:00
parent b0c74459ab
commit c8e0e51b8d
3 changed files with 7 additions and 14 deletions

View file

@ -6,15 +6,15 @@ SHARED_LIB = libsparsemap.so
LIBS = -lm LIBS = -lm
#CFLAGS = -Wall -Wextra -Wpedantic -Of -std=c11 -Iinclude/ -fPIC #CFLAGS = -Wall -Wextra -Wpedantic -Of -std=c11 -Iinclude/ -fPIC
#CFLAGS = -Wall -Wextra -Wpedantic -Og -g -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 -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 -Ofast -g -std=c11 -Iinclude/ -fPIC
#CFLAGS = -Wall -Wextra -Wpedantic -Og -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 = -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 = -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 #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 = -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 -Ofast -g -std=c11 -Iinclude/ -Itests/ -fPIC
#TEST_FLAGS = -Wall -Wextra -Wpedantic -Og -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 #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

View file

@ -1431,8 +1431,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source)
{ {
uint8_t *src, *dst; uint8_t *src, *dst;
size_t src_count = __sm_get_chunk_count(source); 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); sparsemap_idx_t dst_ending_offset = sparsemap_get_ending_offset(destination);
if (src_count == 0) { if (src_count == 0) {
@ -1448,8 +1446,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source)
return -remaining_capacity; 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); src = __sm_get_chunk_data(source, 0);
while (src_count) { while (src_count) {
sm_idx_t src_start = *(sm_idx_t *)src; 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); __sm_insert_data(destination, offset, src, sizeof(sm_idx_t) + src_size);
/* Update the chunk count and data_used. */ /* Update the chunk count and data_used. */
__sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1);
i += src_capacity;
src_count--; src_count--;
src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk);
continue; continue;
@ -1499,7 +1494,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source)
} }
/* Update the chunk count and data_used. */ /* Update the chunk count and data_used. */
__sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1);
i += src_capacity;
src_count--; src_count--;
src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk);
continue; continue;
@ -1508,7 +1502,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source)
/* Source and destination and a perfect overlapping pair. */ /* Source and destination and a perfect overlapping pair. */
if (src_start == dst_start && src_capacity == dst_capacity) { if (src_start == dst_start && src_capacity == dst_capacity) {
__sm_merge_chunk(destination, src_start, dst_start, dst_capacity, &dst_chunk, &src_chunk); __sm_merge_chunk(destination, src_start, dst_start, dst_capacity, &dst_chunk, &src_chunk);
i += src_capacity;
src_count--; src_count--;
src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk);
continue; continue;
@ -1525,7 +1518,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source)
sparsemap_set(destination, n, true); sparsemap_set(destination, n, true);
} }
} }
i += src_capacity;
src_count--; src_count--;
src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk);
continue; continue;
@ -1539,7 +1531,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source)
/* Update the chunk count and data_used. */ /* Update the chunk count and data_used. */
__sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1);
i += src_capacity;
src_count--; src_count--;
src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk);
continue; continue;
@ -1552,7 +1543,6 @@ sparsemap_merge(sparsemap_t *destination, sparsemap_t *source)
/* Update the chunk count and data_used. */ /* Update the chunk count and data_used. */
__sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1); __sm_set_chunk_count(destination, __sm_get_chunk_count(destination) + 1);
i += src_capacity;
src_count--; src_count--;
src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk); src += sizeof(sm_idx_t) + __sm_chunk_get_size(&src_chunk);
continue; continue;

View file

@ -543,6 +543,9 @@ test_api_get_data(const MunitParameter params[], void *data)
assert_true(sparsemap_get_data(map) == buf); assert_true(sparsemap_get_data(map) == buf);
munit_free(buf);
munit_free(map);
return MUNIT_OK; return MUNIT_OK;
} }