mirror of https://github.com/xzeldon/htop.git
Replace copy loop by memmove in Vector_insert
This is basically the same change like in Vector_take, just in the opposite direction.
This commit is contained in:
parent
1704c29b90
commit
164051354f
4
Vector.c
4
Vector.c
|
@ -190,8 +190,8 @@ void Vector_insert(Vector* this, int idx, void* data_) {
|
||||||
|
|
||||||
Vector_checkArraySize(this);
|
Vector_checkArraySize(this);
|
||||||
//assert(this->array[this->items] == NULL);
|
//assert(this->array[this->items] == NULL);
|
||||||
for (int i = this->items; i > idx; i--) {
|
if(idx < this->items) {
|
||||||
this->array[i] = this->array[i-1];
|
memmove(&this->array[idx + 1], &this->array[idx], (this->items - idx) * sizeof(this->array[0]));
|
||||||
}
|
}
|
||||||
this->array[idx] = data;
|
this->array[idx] = data;
|
||||||
this->items++;
|
this->items++;
|
||||||
|
|
Loading…
Reference in New Issue