MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / __array_at_checked_impl

Function __array_at_checked_impl

array/array.h:101–107  ·  view source on GitHub ↗

* @brief Internal implementation of array_at_checked. * * Returns a pointer to the element at `index`, or NULL when `index` * is out of range. Unlike the raw `array_at` accessor, this performs a * bounds check before computing the address. */

Source from the content-addressed store, hash-verified

99 * is out of range. Unlike the raw `array_at` accessor, this performs a
100 * bounds check before computing the address.
101 */
102/* The lookup helpers take `const void*` (like strchr), so they work on a
103 const array too (passing its data used to discard the qualifier); the
104 result must then only be read. */
105static inline void *arrayp_at_checked_impl(const void *data, size_t count,
106 size_t elem_size, size_t index) {
107 if (index >= count) {
108 return NULL;
109 }
110 return (unsigned char *)(uintptr_t)data + index * elem_size;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected