From 8fea5ca7104c0d95108947661a4991b61b2ee06e Mon Sep 17 00:00:00 2001 From: Chris Hall Date: Tue, 6 Apr 2010 02:10:30 +0100 Subject: First beta release Various bug fixes and improvements. Running with a fair amount of debug/assert code, which must be removed at some date. --- lib/vector.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'lib/vector.c') diff --git a/lib/vector.c b/lib/vector.c index 3fb4cbd9..646f19a5 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -855,32 +855,26 @@ vector_sak(int to_copy, vector to, * Legacy Vector Operations */ -/* This function only returns next empty slot index. It does not mean - the slot's index memory is assigned, please call vector_ensure() - after calling this function. - - Index returned is <= current (logical) end. -*/ +/* Set value to the smallest empty slot. */ int -vector_empty_slot (vector v) +vector_set (vector v, void *val) { vector_index i; - for (i = 0; i < v->end; i++) - if (v->p_items[i] == NULL) - break ; + i = 0 ; + while (1) + { + if (i == v->end) + { + i = vector_extend_by_1(v) ; + break ; + } - return i; -} + if (v->p_items[i] == NULL) + break ; -/* Set value to the smallest empty slot. */ -int -vector_set (vector v, void *val) -{ - vector_index i; - i = vector_empty_slot(v) ; /* NB: i <= v->end */ - if (i == v->end) - i = vector_extend_by_1(v) ; + ++i ; + } ; v->p_items[i] = val; -- cgit v1.2.3