Documentation.

This commit is contained in:
Neil 2021-03-21 14:50:30 -07:00
parent 822cc4e4ba
commit 23f3bdb722

View File

@ -47,10 +47,11 @@ static int name##_array_reserve(struct name##_array *const a, \
a->data = data, a->capacity = c0; \ a->data = data, a->capacity = c0; \
return 1; \ return 1; \
} \ } \
/** Adds at least `buffer` un-initialised and uncounted elements at the back of /** Makes sure that there are at least `buffer` contiguous, un-initialised,
`a`. @return A pointer to the start of `buffer` elements, namely elements at the back of `a`.
`data + size`. If `a` is idle and `buffer` is zero, a null pointer is @return A pointer to the start of `buffer` elements, namely `a.data + a.size`.
returned, otherwise this indicates an error. @throws[realloc, ERANGE] */ \ If `a` is idle and `buffer` is zero, a null pointer is returned, otherwise
null indicates an error and `errno` will be set. @throws[realloc, ERANGE] */ \
static type *name##_array_buffer(struct name##_array *const a, \ static type *name##_array_buffer(struct name##_array *const a, \
const size_t buffer) { \ const size_t buffer) { \
assert(a); \ assert(a); \
@ -59,8 +60,8 @@ static type *name##_array_buffer(struct name##_array *const a, \
if(!name##_array_reserve(a, a->size + buffer)) return 0; \ if(!name##_array_reserve(a, a->size + buffer)) return 0; \
return a->data ? a->data + a->size : 0; \ return a->data ? a->data + a->size : 0; \
} \ } \
/** Emplaces `n` elements on `a`. `n` must be smaller than or equal to the /** Adds `n` to the size of `a`; `n` must be smaller than or equal to the
highest remaining <fn:<name>_array_buffer>. */ \ highest remaining buffer value set by <fn:<name>_array_buffer>. */ \
static void name##_array_emplace(struct name##_array *const a, \ static void name##_array_emplace(struct name##_array *const a, \
const size_t n) { \ const size_t n) { \
assert(a && a->capacity >= a->size && n <= a->capacity - a->size); \ assert(a && a->capacity >= a->size && n <= a->capacity - a->size); \