diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-04-06 02:10:30 +0100 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-04-06 02:10:30 +0100 |
commit | 8fea5ca7104c0d95108947661a4991b61b2ee06e (patch) | |
tree | 7ad44a658a61d4a8dfb43ca5b6122c5626f68ea0 /lib/vector.c | |
parent | c933cf7233f51f677ab01689f175ceb3dc5361f6 (diff) | |
download | quagga-8fea5ca7104c0d95108947661a4991b61b2ee06e.tar.bz2 quagga-8fea5ca7104c0d95108947661a4991b61b2ee06e.tar.xz |
First beta release
Various bug fixes and improvements.
Running with a fair amount of debug/assert code, which must be
removed at some date.
Diffstat (limited to 'lib/vector.c')
-rw-r--r-- | lib/vector.c | 34 |
1 files changed, 14 insertions, 20 deletions
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; |