equal
deleted
inserted
replaced
36 /* Doubles the allocated size associated to a pointer */ |
36 /* Doubles the allocated size associated to a pointer */ |
37 /* 'size' is the current allocated size. */ |
37 /* 'size' is the current allocated size. */ |
38 static void * mem_double(void * ptr, int size) |
38 static void * mem_double(void * ptr, int size) |
39 { |
39 { |
40 void * newptr ; |
40 void * newptr ; |
41 |
41 |
42 newptr = calloc(2*size, 1); |
42 newptr = calloc(2*size, 1); |
43 if (newptr==NULL) { |
43 if (newptr==NULL) { |
44 return NULL ; |
44 return NULL ; |
45 } |
45 } |
46 memcpy(newptr, ptr, size); |
46 memcpy(newptr, ptr, size); |
222 { |
222 { |
223 int i ; |
223 int i ; |
224 unsigned hash ; |
224 unsigned hash ; |
225 |
225 |
226 if (d==NULL || key==NULL) return -1 ; |
226 if (d==NULL || key==NULL) return -1 ; |
227 |
227 |
228 /* Compute hash for this key */ |
228 /* Compute hash for this key */ |
229 hash = dictionary_hash(key) ; |
229 hash = dictionary_hash(key) ; |
230 /* Find if value is already in dictionary */ |
230 /* Find if value is already in dictionary */ |
231 if (d->n>0) { |
231 if (d->n>0) { |
232 for (i=0 ; i<d->size ; i++) { |
232 for (i=0 ; i<d->size ; i++) { |
365 char cval[90] ; |
365 char cval[90] ; |
366 |
366 |
367 /* Allocate dictionary */ |
367 /* Allocate dictionary */ |
368 printf("allocating...\n"); |
368 printf("allocating...\n"); |
369 d = dictionary_new(0); |
369 d = dictionary_new(0); |
370 |
370 |
371 /* Set values in dictionary */ |
371 /* Set values in dictionary */ |
372 printf("setting %d values...\n", NVALS); |
372 printf("setting %d values...\n", NVALS); |
373 for (i=0 ; i<NVALS ; i++) { |
373 for (i=0 ; i<NVALS ; i++) { |
374 sprintf(cval, "%04d", i); |
374 sprintf(cval, "%04d", i); |
375 dictionary_set(d, cval, "salut"); |
375 dictionary_set(d, cval, "salut"); |