Compare commits
No commits in common. "047babeb1b1e4258a1f78c25d3a355b1f6c8e17c" and "79aa314352d99a44ca6ab5c935d4e63b3cfc51c3" have entirely different histories.
047babeb1b
...
79aa314352
5
main.cpp
5
main.cpp
@ -15,7 +15,6 @@ void test_basics(amap mapdo, void *map) {
|
||||
|
||||
/* Delete / tombstone */
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning", NULL));
|
||||
assert(NULL == (int *)mapdo(map, AMAP_GET, "meaning", NULL));
|
||||
|
||||
/* Check re-adding */
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning", &i));
|
||||
@ -27,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, "meaningless1", &i));
|
||||
assert(NULL != mapdo(map, AMAP_SET, "meaning1", &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... */
|
||||
@ -38,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, "meaningless1", NULL)));
|
||||
assert(NULL != (iptr = (int *)mapdo(map, AMAP_GET, "meaning1", NULL)));
|
||||
assert(*iptr == 42);
|
||||
assert(iptr == &i);
|
||||
}
|
||||
|
10
simap.h
10
simap.h
@ -140,8 +140,6 @@ static inline unsigned int get_size_padding(unsigned int size, unsigned int alig
|
||||
static inline uint32_t simap_elem_storage_size(const char *key) {
|
||||
uint32_t keysize = strlen(key);
|
||||
uint32_t padding = get_size_padding(keysize, 8);
|
||||
/* XXX: The exactly 8byte keys need a zero terminator too (would be overridden without this) */
|
||||
padding += (keysize == 8) ? 8 : 0;
|
||||
|
||||
return keysize +
|
||||
sizeof(simap_ptr64) +
|
||||
@ -175,17 +173,18 @@ 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;
|
||||
|
||||
/* 8byte: Save data ptr */
|
||||
/* Save data ptr */
|
||||
simap_ptr64 *data = (simap_ptr64 *)((uint8_t *)(map->base) + usi);
|
||||
data->ptr = ptr;
|
||||
|
||||
/* 8byte: Save link to previous and next */
|
||||
/* Save link to previous */
|
||||
uint32_t *usprev = (uint32_t *)((uint8_t *)(map->base) + usi +
|
||||
sizeof(simap_ptr64));
|
||||
*usprev = previ;
|
||||
/* and nex */
|
||||
*(usprev + 1) = (uint32_t) -1;
|
||||
|
||||
/* 8byte: First 8 char */
|
||||
/* First 8 bytes */
|
||||
simap_c64 *start_str = (simap_c64 *)(usprev + 2);
|
||||
*start_str = first8;
|
||||
|
||||
@ -195,7 +194,6 @@ static inline void *simap_force_add_internal(simap_instance *map, const char *ke
|
||||
char *rem_str = (char *)(start_str + 1);
|
||||
strcpy(rem_str, key + 8);
|
||||
}
|
||||
/* XXX: The "padding" gets automagically added by the movement of the arena here(by junk bytes)! */
|
||||
|
||||
/* Update previous with linkage */
|
||||
if(previ != (uint32_t)-1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user