src/array_list.c

changeset 666
b5dd654deb3b
parent 664
af5bf4603a5d
child 667
2f88a7c13a28
equal deleted inserted replaced
665:c4041b07165e 666:b5dd654deb3b
308 char *ptr = arl->data; 308 char *ptr = arl->data;
309 309
310 switch (list->content_destructor_type) { 310 switch (list->content_destructor_type) {
311 case CX_DESTRUCTOR_SIMPLE: { 311 case CX_DESTRUCTOR_SIMPLE: {
312 for (size_t i = 0; i < list->size; i++) { 312 for (size_t i = 0; i < list->size; i++) {
313 list->simple_destructor(ptr); 313 cx_list_invoke_simple_destructor(list, ptr);
314 ptr += list->itemsize; 314 ptr += list->itemsize;
315 } 315 }
316 break; 316 break;
317 } 317 }
318 case CX_DESTRUCTOR_ADVANCED: { 318 case CX_DESTRUCTOR_ADVANCED: {
319 for (size_t i = 0; i < list->size; i++) { 319 for (size_t i = 0; i < list->size; i++) {
320 list->advanced_destructor.func(list->advanced_destructor.data, 320 cx_list_invoke_advanced_destructor(list, ptr);
321 ptr);
322 ptr += list->itemsize; 321 ptr += list->itemsize;
323 } 322 }
324 break; 323 break;
325 } 324 }
326 case CX_DESTRUCTOR_NONE: 325 case CX_DESTRUCTOR_NONE:
327 break; // nothing 326 break; // nothing
328 } 327 }
328
329 memset(arl->data, 0, list->size * list->itemsize);
330 list->size = 0;
329 } 331 }
330 332
331 static int cx_arl_swap( 333 static int cx_arl_swap(
332 struct cx_list_s *list, 334 struct cx_list_s *list,
333 size_t i, 335 size_t i,

mercurial