492 |
492 |
493 void cxListFree(CxList *list) { |
493 void cxListFree(CxList *list) { |
494 if (list == NULL) return; |
494 if (list == NULL) return; |
495 list->cl->deallocate(list); |
495 list->cl->deallocate(list); |
496 } |
496 } |
|
497 |
|
498 int cxListSet( |
|
499 CxList *list, |
|
500 size_t index, |
|
501 const void *elem |
|
502 ) { |
|
503 if (index >= list->collection.size) { |
|
504 return 1; |
|
505 } |
|
506 |
|
507 if (list->collection.store_pointer) { |
|
508 // For pointer collections, always use climpl |
|
509 void **target = list->climpl->at(list, index); |
|
510 *target = (void *)elem; |
|
511 } else { |
|
512 void *target = list->cl->at(list, index); |
|
513 memcpy(target, elem, list->collection.elem_size); |
|
514 } |
|
515 |
|
516 return 0; |
|
517 } |