diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2006-11-12 21:52:14 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2006-11-12 21:52:14 +0000 |
commit | 36848494f57ff8cdc95876c95c36052eca40ccdb (patch) | |
tree | d3d50472fa7098e2a27127899e7a9ed20af22fc0 /Vector.c | |
parent | c90a4451032d54c3f29cd6b567ba62126fe65208 (diff) |
Add debugging sanity checks.
Diffstat (limited to 'Vector.c')
-rw-r--r-- | Vector.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -74,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) { @@ -223,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)); } |