diff --git a/m-array.h b/m-array.h index dcb9e200..2ca5b05e 100644 --- a/m-array.h +++ b/m-array.h @@ -583,16 +583,16 @@ } \ \ static inline void \ - M_C3(array_, name, _insert)(array_it_t it, type const x) \ + M_C3(array_, name, _insert)(array_t a, array_it_t it, type const x) \ { \ - assert(it != NULL); \ - M_C3(array_, name, _push_at)(it->array, it->index, x); \ + assert (it != NULL && a == it->array); \ + M_C3(array_, name, _push_at)(a, it->index, x); \ } \ \ static inline void \ M_C3(array_,name, _remove)(array_t a, array_it_t it) \ { \ - assert (a == it->array); \ + assert (it != NULL && a == it->array); \ M_C3(array_, name, _pop_at)(NULL, a, it->index); \ /* NOTE: it->index will naturaly point to the next element */ \ } \ diff --git a/tests/test-marray.c b/tests/test-marray.c index 7659b44c..2b3b6793 100644 --- a/tests/test-marray.c +++ b/tests/test-marray.c @@ -275,7 +275,7 @@ static void test_d(void) array_uint_it_set (it2, it); assert (array_uint_it_equal_p(it2, it)); assert (*array_uint_ref(it2) == 0); - array_uint_insert(it2, 17); + array_uint_insert(a1, it2, 17); assert (array_uint_size(a1) == 300); array_uint_init_set (a2, a1);