docs/src/features.md

changeset 819
5da2ead43077
parent 746
b4bd0155f03f
child 831
7970eac1c598
     1.1 --- a/docs/src/features.md	Thu Jan 25 22:01:12 2024 +0100
     1.2 +++ b/docs/src/features.md	Thu Jan 25 22:05:48 2024 +0100
     1.3 @@ -281,7 +281,7 @@
     1.4  However, there is one extremely powerful function that can be used for several complex tasks: `cx_array_copy`.
     1.5  The full signature is shown below:
     1.6  ```c
     1.7 -enum cx_array_copy_result cx_array_copy(
     1.8 +enum cx_array_result cx_array_copy(
     1.9          void **target,
    1.10          size_t *size,
    1.11          size_t *capacity,  // optional
    1.12 @@ -295,19 +295,19 @@
    1.13  The `target` argument is a pointer to the target array pointer.
    1.14  The reason for this additional indirection is that - given that you provide a `reallocator` - this function writes
    1.15  back the pointer to the possibly reallocated array.
    1.16 -THe next two arguments are pointers to the `size` and `capacity` of the target array.
    1.17 +The next two arguments are pointers to the `size` and `capacity` of the target array.
    1.18  Tracking the capacity is optional.
    1.19  If you do not specify a pointer for the capacity, automatic reallocation of the array is entirely disabled (i.e. it
    1.20  does not make sense to specify a `reallocator` then).
    1.21  In this case, the function cannot copy more than `size-index` elements and if you try, it will return
    1.22 -`CX_ARRAY_COPY_REALLOC_NOT_SUPPORTED` and do nothing.
    1.23 +`CX_ARRAY_REALLOC_NOT_SUPPORTED` and do nothing.
    1.24  
    1.25  On a successful invocation, the function copies `elem_count` number of elements, each of size `elem_size` from
    1.26  `src` to `*target` and uses the `reallocator` to extend the array when necessary.
    1.27  Finally, the size, capacity, and the pointer to the array are all updated and the function returns
    1.28 -`CX_ARRAY_COPY_SUCCESS`.
    1.29 +`CX_ARRAY_SUCCESS`.
    1.30  
    1.31 -The third, but extremely rare, return code is `CX_ARRAY_COPY_REALLOC_FAILED` and speaks for itself.
    1.32 +The third, but extremely rare, return code is `CX_ARRAY_REALLOC_FAILED` and speaks for itself.
    1.33  
    1.34  A few things to note:
    1.35  * `*target` and `src` can point to the same memory region, effectively copying elements within the array with `memmove`
    1.36 @@ -316,6 +316,8 @@
    1.37  * `index` does not need to be within size of the current array, if `capacity` is specified
    1.38  * `index` does not even need to be within the capacity of the array, if `reallocator` is specified 
    1.39  
    1.40 +If you just want to add one single element to an existing array, you can use the macro `cx_array_add()`.
    1.41 +In that case, since the element is added to the end of the array, the `capacity` argument is mandatory.
    1.42  
    1.43  ## Map
    1.44  

mercurial