1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-10 07:44:14 +01:00

fixed WMInsertInBag

This commit is contained in:
dan
1999-10-07 19:13:05 +00:00
parent 28636cc873
commit 1401269ae4

View File

@@ -74,7 +74,15 @@ WMInsertInBag(WMBag *bag, int index, void *item)
bag->items = wrealloc(bag->items, sizeof(void*) * bag->size);
}
bag->items[bag->count++] = item;
if (index >= 0 && index < bag->count) {
memmove(&bag->items[index+1], &bag->items[index],
(bag->count - index) * sizeof(void*));
} else {
/* If index is invalid, place it at end */
index = bag->count;
}
bag->items[index] = item;
bag->count++;
}