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

Function _array__splice

codegraph-kernel/grammars/dart/tree_sitter/array.h:256–293  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

254
255/// This is not what you're looking for, see `array_splice`.
256static inline void *_array__splice(void *self_contents, uint32_t *size, uint32_t *capacity,
257 size_t element_size,
258 uint32_t index, uint32_t old_count,
259 uint32_t new_count, const void *elements) {
260 uint32_t new_size = *size + new_count - old_count;
261 uint32_t old_end = index + old_count;
262 uint32_t new_end = index + new_count;
263 assert(old_end <= *size);
264
265 void *new_contents = _array__reserve(self_contents, capacity, element_size, new_size);
266
267 char *contents = (char *)new_contents;
268 if (*size > old_end) {
269 memmove(
270 contents + new_end * element_size,
271 contents + old_end * element_size,
272 (*size - old_end) * element_size
273 );
274 }
275 if (new_count > 0) {
276 if (elements) {
277 memcpy(
278 (contents + index * element_size),
279 elements,
280 new_count * element_size
281 );
282 } else {
283 memset(
284 (contents + index * element_size),
285 0,
286 new_count * element_size
287 );
288 }
289 }
290 *size += new_count - old_count;
291
292 return new_contents;
293}
294
295/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
296/// 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