docs/Writerside/topics/list.h.md

changeset 1444
dd9dcbb39c2f
parent 1441
78ec3e2243e4
equal deleted inserted replaced
1443:6986e9ed70f3 1444:dd9dcbb39c2f
362 const CxAllocator *allocator, 362 const CxAllocator *allocator,
363 void *data); 363 void *data);
364 364
365 #include <cx/list.h> 365 #include <cx/list.h>
366 366
367 size_t cxListClone(CxList *dst, const CxList *src, 367 int cxListClone(CxList *dst, const CxList *src,
368 cx_clone_func clone_func, 368 cx_clone_func clone_func,
369 const CxAllocator *clone_allocator, 369 const CxAllocator *clone_allocator,
370 void *data); 370 void *data);
371 ``` 371 ```
372 372
375 Depending on the concrete list implementation, `cxListClone()` tries to allocate enough memory up-front, before trying 375 Depending on the concrete list implementation, `cxListClone()` tries to allocate enough memory up-front, before trying
376 to insert anything. 376 to insert anything.
377 377
378 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it. 378 Refer to the documentation of the [clone-function callback](allocator.h.md#clone-function) to learn how to implement it.
379 379
380 The function returns the number of elements successfully cloned. 380 The function returns zero if and only if all clone operations were successful.
381 If an allocation error occurs, this might be smaller than the size of the source list.
382 381
383 > It is perfectly possible to clone items into a list of a different type. 382 > It is perfectly possible to clone items into a list of a different type.
384 > For example, you can clone elements from a list that is just storing pointers (`CX_STORE_POINTERS`) to a list that 383 > For example, you can clone elements from a list that is just storing pointers (`CX_STORE_POINTERS`) to a list that
385 > allocates the memory for the objects (and vice versa). 384 > allocates the memory for the objects (and vice versa).
386 385

mercurial