diff --git a/main.cpp b/main.cpp index 76161c6..c3bc40b 100644 --- a/main.cpp +++ b/main.cpp @@ -26,7 +26,7 @@ void test_basics(amap mapdo, void *map) { assert(NULL != mapdo(map, AMAP_ERASE, NULL, NULL)); /* Check re-adding 3 new things */ - assert(NULL != mapdo(map, AMAP_SET, "meaning1", &i)); + assert(NULL != mapdo(map, AMAP_SET, "meaningless1", &i)); assert(NULL != mapdo(map, AMAP_SET, "meaning2", &i)); const char *helloworld = "Hello world!"; assert(NULL != mapdo(map, AMAP_SET, "hello", (char *)helloworld)); /* TODO: ugly cast... */ @@ -37,7 +37,7 @@ void test_basics(amap mapdo, void *map) { assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaning2", NULL))); assert(*iptr == 42); assert(iptr == &i); - assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaning1", NULL))); + assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaningless1", NULL))); assert(*iptr == 42); assert(iptr == &i); } diff --git a/simap.h b/simap.h index bbaf8a8..9ccd852 100644 --- a/simap.h +++ b/simap.h @@ -173,18 +173,17 @@ static inline void *simap_force_add_internal(simap_instance *map, const char *ke uint32_t usi = map->usage_end; uint32_t previ = map->prev_usage_end; - /* Save data ptr */ + /* 8byte: Save data ptr */ simap_ptr64 *data = (simap_ptr64 *)((uint8_t *)(map->base) + usi); data->ptr = ptr; - /* Save link to previous */ + /* 8byte: Save link to previous and next */ uint32_t *usprev = (uint32_t *)((uint8_t *)(map->base) + usi + sizeof(simap_ptr64)); *usprev = previ; - /* and nex */ *(usprev + 1) = (uint32_t) -1; - /* First 8 bytes */ + /* 8byte: First 8 char */ simap_c64 *start_str = (simap_c64 *)(usprev + 2); *start_str = first8;