aboutsummaryrefslogtreecommitdiffstats
path: root/Vector.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:07 +0200
commitff9409b1737627857eb47f64f536a3f66b6a09a4 (patch)
tree61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /Vector.c
parentf75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff)
downloaddebian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2
debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'Vector.c')
-rw-r--r--Vector.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Vector.c b/Vector.c
index f3212f8..0cdf9af 100644
--- a/Vector.c
+++ b/Vector.c
@@ -37,9 +37,9 @@ Vector* Vector_new(ObjectClass* type, bool owner, int size) {
if (size == DEFAULT_SIZE)
size = 10;
- this = (Vector*) malloc(sizeof(Vector));
+ this = xMalloc(sizeof(Vector));
this->growthRate = size;
- this->array = (Object**) calloc(size, sizeof(Object*));
+ this->array = (Object**) xCalloc(size, sizeof(Object*));
this->arraySize = size;
this->items = 0;
this->type = type;
@@ -179,7 +179,7 @@ static void Vector_checkArraySize(Vector* this) {
//int i;
//i = this->arraySize;
this->arraySize = this->items + this->growthRate;
- this->array = (Object**) realloc(this->array, sizeof(Object*) * this->arraySize);
+ this->array = (Object**) xRealloc(this->array, sizeof(Object*) * this->arraySize);
//for (; i < this->arraySize; i++)
// this->array[i] = NULL;
}
@@ -189,9 +189,12 @@ static void Vector_checkArraySize(Vector* this) {
void Vector_insert(Vector* this, int idx, void* data_) {
Object* data = data_;
assert(idx >= 0);
- assert(idx <= this->items);
assert(Object_isA(data, this->type));
assert(Vector_isConsistent(this));
+
+ if (idx > this->items) {
+ idx = this->items;
+ }
Vector_checkArraySize(this);
//assert(this->array[this->items] == NULL);

© 2014-2024 Faster IT GmbH | imprint | privacy policy