paysages3d/src/system/Memory.cpp
2016-07-23 22:58:32 +02:00

21 lines
577 B
C++

#include "Memory.h"
#include <cassert>
#include <cstdlib>
#include <cstring>
void *Memory::naiveArrayInsert(void **array, unsigned long item_size, int item_count, int location) {
char **barray = (char **)array;
assert(location >= 0);
assert(location <= item_count);
*barray = (char *)realloc(*barray, item_size * (item_count + 1));
if (location < item_count) {
memmove(*barray + item_size * (location + 1), *barray + item_size * location,
item_size * (item_count - location));
}
return *barray + item_size * location;
}