diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:21 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:21 +0200 |
commit | 9675cf654d86464344e56705db7a71ea17f76c6f (patch) | |
tree | 86077a344c002694db7ba4f7295d8a64b3601258 /Vector.c | |
parent | 85bb4ad9cb820ac3b8e935a930084a06cbfd2847 (diff) | |
download | debian_htop-9675cf654d86464344e56705db7a71ea17f76c6f.tar.gz debian_htop-9675cf654d86464344e56705db7a71ea17f76c6f.tar.bz2 debian_htop-9675cf654d86464344e56705db7a71ea17f76c6f.zip |
Imported Upstream version 0.6.6+svn20070915upstream/0.6.6+svn20070915
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)); } |