From: David Given Date: Sat, 21 Jan 2017 22:21:55 +0000 (+0100) Subject: Fix bug where pop would return the wrong value. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=496351c6f9a4ae111f727bcd27453bd683e4668b;p=ack.git Fix bug where pop would return the wrong value. --- diff --git a/modules/src/data/array.c b/modules/src/data/array.c index 363e60373..2168c7d35 100644 --- a/modules/src/data/array.c +++ b/modules/src/data/array.c @@ -21,8 +21,7 @@ void array_append(void* arrayp, void* value) struct array* array = arrayp; extend(array); - array->item[array->count] = value; - array->count++; + array->item[array->count++] = value; } int array_indexof(void* arrayp, void* value) @@ -99,7 +98,7 @@ void* array_pop(void* arrayp) struct array* array = arrayp; assert(array->count > 0); - return array->item[array->count--]; + return array->item[--array->count]; } void array_appendall(void* arrayp, void* srcp)