This is not what you're looking for, see `array_splice`.
| 218 | |
| 219 | /// This is not what you're looking for, see `array_splice`. |
| 220 | static 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`. |
nothing calls this directly
no test coverage detected