better growth
This commit is contained in:
parent
67e2652363
commit
2cdcdc167f
2
arena.h
2
arena.h
@ -1 +1 @@
|
|||||||
Subproject commit 70f97b8291454efbf9606051352c15ea6ebca319
|
Subproject commit 3037bf6bec96b0ebc231510d308da1daece276fd
|
12
simap.h
12
simap.h
@ -144,10 +144,16 @@ static inline uint32_t simap_elem_storage_size(const char *key) {
|
|||||||
/** Force-add the (key,value) to the end of the map */
|
/** Force-add the (key,value) to the end of the map */
|
||||||
static inline void *simap_force_add_internal(simap_instance *map, const char *key, void *ptr) {
|
static inline void *simap_force_add_internal(simap_instance *map, const char *key, void *ptr) {
|
||||||
uint32_t storage_needed = simap_elem_storage_size(key);
|
uint32_t storage_needed = simap_elem_storage_size(key);
|
||||||
|
assert((storage_needed & 8) == 0);
|
||||||
if(map->end - map->usage_end > storage_needed) {
|
if(map->end - map->usage_end > storage_needed) {
|
||||||
/* Need storage */
|
/* Need storage */
|
||||||
/* TODO: Implement */
|
aralloc(&(map->a),
|
||||||
// Soemthin' like = ((T*) alloc(&a, sizeof(T), sizeof(T), 1)) + 1;
|
sizeof(uint8_t)/*esize*/,
|
||||||
|
1 /*align - should be 8 but should be aligned here as-is! */,
|
||||||
|
storage_needed);
|
||||||
|
|
||||||
|
/* Administer end offset */
|
||||||
|
map->end += storage_needed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Already have the storage */
|
/* Already have the storage */
|
||||||
@ -191,9 +197,11 @@ static inline void* simap(void *amap_instance, AMAP_OP op, const char *key, void
|
|||||||
found->ptr = ptr;
|
found->ptr = ptr;
|
||||||
return (void *) found;
|
return (void *) found;
|
||||||
} else {
|
} else {
|
||||||
|
return simap_force_add_internal(map, key, ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(false); /* should be unreachable */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user