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 |