src/kv_list.c

changeset 1361
cdc3242a9b33
parent 1360
8b29d732f97b
child 1362
d886626a9526
equal deleted inserted replaced
1360:8b29d732f97b 1361:cdc3242a9b33
212 // therefore, we re-implement the logic ourselves 212 // therefore, we re-implement the logic ourselves
213 213
214 // check if the outside caller want's us to return or to destroy the element 214 // check if the outside caller want's us to return or to destroy the element
215 if (targetbuf == NULL) { 215 if (targetbuf == NULL) {
216 // destroy the element 216 // destroy the element
217 // invoke all destructors from both the list and the map aspect
218 // (usually the user will only use one of the aspects anyway and if not, it's documented)
217 cx_invoke_destructor(&kv_list->list.list_base, node_data); 219 cx_invoke_destructor(&kv_list->list.list_base, node_data);
220 // note that we cannot use the macro, because it will use the wrong store_pointer information
221 CxMap *map_aspect = &kv_list->map->map_base.base;
222 if (map_aspect->collection.simple_destructor) {
223 map_aspect->collection.simple_destructor(
224 kv_list->list.list_base.collection.store_pointer ? *(void**)node_data : node_data);
225 }
226 if (map_aspect->collection.advanced_destructor) {
227 map_aspect->collection.advanced_destructor(map_aspect->collection.destructor_data,
228 kv_list->list.list_base.collection.store_pointer ? *(void**)node_data : node_data);
229 }
218 } else { 230 } else {
219 // copy the element to the target buffer 231 // copy the element to the target buffer
220 memcpy(targetbuf, node_data, kv_list->list.list_base.collection.elem_size); 232 memcpy(targetbuf, node_data, kv_list->list.list_base.collection.elem_size);
221 } 233 }
222 234

mercurial