MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / _array__splice

Function _array__splice

codegraph-kernel/grammars/lua/tree_sitter/array.h:220–254  ·  view source on GitHub ↗

This is not what you're looking for, see `array_splice`.

Source from the content-addressed store, hash-verified

218
219/// This is not what you're looking for, see `array_splice`.
220static inline void _array__splice(Array *self, size_t element_size,
221 uint32_t index, uint32_t old_count,
222 uint32_t new_count, const void *elements) {
223 uint32_t new_size = self->size + new_count - old_count;
224 uint32_t old_end = index + old_count;
225 uint32_t new_end = index + new_count;
226 assert(old_end <= self->size);
227
228 _array__reserve(self, element_size, new_size);
229
230 char *contents = (char *)self->contents;
231 if (self->size > old_end) {
232 memmove(
233 contents + new_end * element_size,
234 contents + old_end * element_size,
235 (self->size - old_end) * element_size
236 );
237 }
238 if (new_count > 0) {
239 if (elements) {
240 memcpy(
241 (contents + index * element_size),
242 elements,
243 new_count * element_size
244 );
245 } else {
246 memset(
247 (contents + index * element_size),
248 0,
249 new_count * element_size
250 );
251 }
252 }
253 self->size += new_count - old_count;
254}
255
256/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
257/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.

Callers

nothing calls this directly

Calls 1

_array__reserveFunction · 0.70

Tested by

no test coverage detected