src/kv_list.c

changeset 1371
37dcaeebe5ca
parent 1370
607f822c79fe
child 1372
9c176073e771
equal deleted inserted replaced
1370:607f822c79fe 1371:37dcaeebe5ca
355 struct cx_kv_list_map_s *kv_map = cxRealloc(allocator, map, sizeof(struct cx_kv_list_map_s)); 355 struct cx_kv_list_map_s *kv_map = cxRealloc(allocator, map, sizeof(struct cx_kv_list_map_s));
356 356
357 // reallocate the list to add memory for storing the metadata 357 // reallocate the list to add memory for storing the metadata
358 cx_kv_list *kv_list = cxRealloc(allocator, list, sizeof(struct cx_kv_list_s)); 358 cx_kv_list *kv_list = cxRealloc(allocator, list, sizeof(struct cx_kv_list_s));
359 359
360 // zero the custom destructor information
361 memset((char*)kv_list + offsetof(cx_kv_list, list_destr), 0, sizeof(void*)*6);
362
363 // if any of the reallocations failed, we bail out 360 // if any of the reallocations failed, we bail out
364 if (kv_map != NULL && kv_list != NULL) { 361 if (kv_map != NULL && kv_list != NULL) {
365 map = (CxMap*) kv_map; 362 map = (CxMap*) kv_map;
366 list = (CxList*) kv_list; 363 list = (CxList*) kv_list;
367 } else { // LCOV_EXCL_START 364 } else { // LCOV_EXCL_START
368 cxListFree(list); 365 cxListFree(list);
369 cxMapFree(map); 366 cxMapFree(map);
370 return NULL; 367 return NULL;
371 } // LCOV_EXCL_STOP 368 } // LCOV_EXCL_STOP
372 369
370 // zero the custom destructor information
371 memset((char*)kv_list + offsetof(cx_kv_list, list_destr), 0, sizeof(void*)*6);
372
373 // combine the list and the map aspect 373 // combine the list and the map aspect
374 kv_list->map = kv_map; 374 kv_list->map = kv_map;
375 kv_map->list = kv_list; 375 kv_map->list = kv_list;
376 376
377 // remember the base methods and override them 377 // remember the base methods and override them

mercurial