a vector_remove shouldn't clear the vector when failing to reallocate as a smaller chunk, just return false. The value is still removed from the vector, so no unstable state is generated by this, which makes a _remove safe to ignore where it makes sense.

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-04-27 13:53:49 +02:00
parent ce43a35307
commit 9867ce26b3

View file

@ -73,10 +73,8 @@ bool GMQCC_WARN Tself##_##mem##_remove(Tself *self, size_t idx) \
{ \
self->mem##_alloc /= 2; \
reall = (Twhat*)mem_a(sizeof(Twhat) * self->mem##_count); \
if (!reall) { \
MEM_VECTOR_CLEAR(self, mem); \
if (!reall) \
return false; \
} \
memcpy(reall, self->mem, sizeof(Twhat) * self->mem##_count); \
mem_d(self->mem); \
self->mem = reall; \