|
|
|
|
@ -6,6 +6,8 @@ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include "dict.h" |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
dict_t** dictAlloc(void){ |
|
|
|
|
return malloc(sizeof(dict_t)); |
|
|
|
|
@ -47,9 +49,11 @@ void delItem(dict_t** dict, char* key){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void addItem(dict_t** dict, char* key, void* value){ |
|
|
|
|
if(((dict_t*)dict)->key !=NULL){ |
|
|
|
|
delItem(dict, key); // if item already exists delete it!
|
|
|
|
|
dict_t *d = malloc(sizeof(struct dict_t_struct)); // new dict
|
|
|
|
|
d->key = malloc(strlen(key)+1); |
|
|
|
|
} |
|
|
|
|
dict_t *d = (dict_t*)malloc(sizeof(struct dict_t_struct)); // new dict
|
|
|
|
|
d->key = (char*)malloc(strlen(key)+1); |
|
|
|
|
// set values
|
|
|
|
|
strcpy(d->key, key); |
|
|
|
|
d->value = value; |
|
|
|
|
|