*oldvalue = ptr[i].value;
if (!value) {
free(ptr[i].key);
- memmove(ptr+i, ptr+i+1, sizeof(struct map_value)*(len-(i+1)));
+ memmove(ptr+i, ptr+i+1, sizeof(map_value)*(len-(i+1)));
len--;
} else {
ptr[i].value = (void *)value;
if (value) {
if (len == cap) {
int ncap = cap ? cap*2 : 2;
- struct map_value *nptr = (struct map_value *)realloc(ptr, sizeof(struct map_value)*ncap);
+ map_value *nptr = (map_value *)realloc(ptr, sizeof(map_value)*ncap);
if (!nptr)
return -1;
ptr = nptr;
if (!nkey)
return -1;
memcpy(nkey, key, slen);
- memmove(ptr+i+1, ptr+i, sizeof(struct map_value)*(len-i));
+ memmove(ptr+i+1, ptr+i, sizeof(map_value)*(len-i));
len++;
ptr[i].key = nkey;
ptr[i].value = (void *)value;
* A map is created by allocating and zero-initializing an object of type
* map_t. All map functions take a pointer to map_t.
*/
-struct map_value {
- char *key;
- void *value;
-};
struct map_base {
- struct map_value *ptr;
+ struct map_value {
+ char *key;
+ void *value;
+ };
+ map_value *ptr;
size_t len, cap;
/* Return the associated value for a given key.
* Dynarr complexity: O(log n) */