| 306 * ) { |
302 * ) { |
| 307 * if (allocator == NULL) { |
303 * if (allocator == NULL) { |
| 308 * allocator = cxDefaultAllocator; |
304 * allocator = cxDefaultAllocator; |
| 309 * } |
305 * } |
| 310 * |
306 * |
| 311 * MyCustomList *list = cxCalloc(allocator, 1, sizeof(MyCustomList)); |
307 * MyCustomList *list = cxZalloc(allocator, sizeof(MyCustomList)); |
| 312 * if (list == NULL) return NULL; |
308 * if (list == NULL) return NULL; |
| 313 * |
309 * |
| 314 * // initialize |
310 * // initialize |
| 315 * cx_list_init((CxList*)list, &my_custom_list_class, |
311 * cx_list_init((CxList*)list, &my_custom_list_class, |
| 316 * allocator, elem_size); |
312 * allocator, elem_size); |
| 328 */ |
324 */ |
| 329 cx_attr_nonnull_arg(1, 2, 3) |
325 cx_attr_nonnull_arg(1, 2, 3) |
| 330 CX_EXPORT void cx_list_init(struct cx_list_s *list, |
326 CX_EXPORT void cx_list_init(struct cx_list_s *list, |
| 331 struct cx_list_class_s *cl, const struct cx_allocator_s *allocator, |
327 struct cx_list_class_s *cl, const struct cx_allocator_s *allocator, |
| 332 size_t elem_size); |
328 size_t elem_size); |
| |
329 |
| |
330 /** |
| |
331 * A @c cx_compare_func2 compatible wrapper for the compare functions of a list. |
| |
332 * |
| |
333 * @param left first element |
| |
334 * @param right second element |
| |
335 * @param list the list which is comparing the elements |
| |
336 * @return the comparison result |
| |
337 */ |
| |
338 cx_attr_nonnull |
| |
339 CX_EXPORT int cx_list_compare_wrapper( |
| |
340 const void *left, const void *right, void *list); |
| 333 |
341 |
| 334 /** |
342 /** |
| 335 * Returns the number of elements currently stored in the list. |
343 * Returns the number of elements currently stored in the list. |
| 336 * |
344 * |
| 337 * @param list the list |
345 * @param list the list |