diff options
author | Bartosz Fenski <fenio@debian.org> | 2007-09-15 14:37:41 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:22 +0200 |
commit | 6e3bbb32d3cd1c09b0d1a79c433e0728a7ea44f4 (patch) | |
tree | 4e5660f891b09b7755a97a75edefdd167365e336 /Vector.c | |
parent | 8ae888dfb193b86560b4d874767c347bf2be8097 (diff) | |
parent | 9675cf654d86464344e56705db7a71ea17f76c6f (diff) | |
download | debian_htop-6e3bbb32d3cd1c09b0d1a79c433e0728a7ea44f4.tar.gz debian_htop-6e3bbb32d3cd1c09b0d1a79c433e0728a7ea44f4.tar.bz2 debian_htop-6e3bbb32d3cd1c09b0d1a79c433e0728a7ea44f4.zip |
Imported Debian patch 0.6.6+svn20070915-1debian/0.6.6+svn20070915-1
Diffstat (limited to 'Vector.c')
-rw-r--r-- | Vector.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -63,6 +63,7 @@ void Vector_delete(Vector* this) { #ifdef DEBUG static inline bool Vector_isConsistent(Vector* this) { + assert(this->items <= this->arraySize); if (this->owner) { for (int i = 0; i < this->items; i++) if (this->array[i] && this->array[i]->class != this->vectorType) @@ -73,6 +74,16 @@ static inline bool Vector_isConsistent(Vector* this) { } } +int Vector_count(Vector* this) { + int items = 0; + for (int i = 0; i < this->items; i++) { + if (this->array[i]) + items++; + } + assert(items == this->items); + return items; +} + #endif void Vector_prune(Vector* this) { @@ -222,8 +233,9 @@ void Vector_add(Vector* this, void* data_) { assert(data_ && ((Object*)data_)->class == this->vectorType); Object* data = data_; assert(Vector_isConsistent(this)); - + int i = this->items; Vector_set(this, this->items, data); + assert(this->items == i+1); (void)(i); assert(Vector_isConsistent(this)); } |