From 496351c6f9a4ae111f727bcd27453bd683e4668b Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 21 Jan 2017 23:21:55 +0100 Subject: [PATCH] Fix bug where pop would return the wrong value. --- modules/src/data/array.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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) -- 2.34.1