wipe elements overwritten by a splice

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
This commit is contained in:
Pierre Habouzit 2008-06-22 20:18:11 +02:00 committed by Julien Danjou
parent 25fc879582
commit dc6373488f
1 changed files with 3 additions and 0 deletions

View File

@ -61,6 +61,9 @@
assert (pos <= arr->len && pos + len < arr->len); \ assert (pos <= arr->len && pos + len < arr->len); \
if (len != count) { \ if (len != count) { \
pfx##_array_grow(arr, arr->len + count - len); \ pfx##_array_grow(arr, arr->len + count - len); \
for (int i = pos; i < pos + len; i++) { \
dtor(&arr->tab[i]); \
} \
memmove(arr->tab + pos + count, arr->tab + pos + len, \ memmove(arr->tab + pos + count, arr->tab + pos + len, \
arr->len - pos - len); \ arr->len - pos - len); \
arr->len += count - len; \ arr->len += count - len; \