From 5378a850b4e717dfcb454ebfb9d8cdb60f454d30 Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Fri, 6 May 2005 23:06:50 +0000 Subject: [PATCH] Bug fixes: initializes properly, releases overwritten elements, doesn't try to free null pointers --- ruamoko/lib/Array.r | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ruamoko/lib/Array.r b/ruamoko/lib/Array.r index 1ddc45fb6..61468aaf1 100644 --- a/ruamoko/lib/Array.r +++ b/ruamoko/lib/Array.r @@ -4,6 +4,7 @@ - (id) init { + self = [super init]; count = size = 0; incr = 16; array = NIL; @@ -21,9 +22,13 @@ - (void) dealloc { local integer i; - for (i = 0; i < count; i++) - [array[i] release]; - obj_free (array); + for (i = 0; i < count; i++) { + if (array[i]) + [array[i] release]; + } + if (array) { + obj_free (array); + } [super dealloc]; } @@ -42,6 +47,7 @@ index = count - 1; if (index < 0 || index >= count) return; + [array[index] release]; array[index] = item; [item retain]; }