Changes in dict.c [f25df21:4c7c21f]
Legend:
- Unmodified
- Added
- Removed
-
dict.c
rf25df21 r4c7c21f 15 15 #define GROWBY 3 / 2 16 16 17 intowl_dict_create(owl_dict *d) {17 void owl_dict_create(owl_dict *d) { 18 18 d->size=0; 19 19 d->els=g_new(owl_dict_el, INITSIZE); 20 20 d->avail=INITSIZE; 21 if (d->els==NULL) return(-1);22 return(0);23 21 } 24 22 … … 60 58 /* Appends dictionary keys to a list. Duplicates the keys, 61 59 * so they will need to be freed by the caller. */ 62 intowl_dict_get_keys(const owl_dict *d, owl_list *l) {60 void owl_dict_get_keys(const owl_dict *d, owl_list *l) { 63 61 int i; 64 char *dupk;65 62 for (i=0; i<d->size; i++) { 66 if ((dupk = g_strdup(d->els[i].k)) == NULL) return(-1); 67 owl_list_append_element(l, dupk); 63 owl_list_append_element(l, g_strdup(d->els[i].k)); 68 64 } 69 return(0);70 65 } 71 66 … … 84 79 { 85 80 int pos, found; 86 char *dupk;87 81 found = _owl_dict_find_pos(d, k, &pos); 88 82 if (found && delete_on_replace) { … … 99 93 if (d->els==NULL) return(-1); 100 94 } 101 if ((dupk = g_strdup(k)) == NULL) return(-1);102 95 if (pos!=d->size) { 103 96 /* shift forward to leave us a slot */ … … 106 99 } 107 100 d->size++; 108 d->els[pos].k = dupk;101 d->els[pos].k = g_strdup(k); 109 102 d->els[pos].v = v; 110 103 return(0);
Note: See TracChangeset
for help on using the changeset viewer.