|
@@ -5,18 +5,18 @@
|
|
|
|
|
|
#include "core/Utility.h"
|
|
|
|
|
|
-static void ensureCapacity(List* l) {
|
|
|
+static void iEnsureListCapacity(List* l) {
|
|
|
if(l->length >= l->capacity) {
|
|
|
reserveListEntries(l, l->capacity + maxSize(4lu, l->capacity / 4));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void setSize(List* l, size_t n) {
|
|
|
+static void iSetListSize(List* l, size_t n) {
|
|
|
l->capacity = n;
|
|
|
l->data = cReallocate(l->data, l->dataSize * n);
|
|
|
}
|
|
|
|
|
|
-static void* getPointer(const List* l, size_t index) {
|
|
|
+static void* iGetListPointer(const List* l, size_t index) {
|
|
|
return (char*)l->data + (l->dataSize * index);
|
|
|
}
|
|
|
|
|
@@ -31,7 +31,7 @@ void destroyList(List* l) {
|
|
|
|
|
|
void reserveListEntries(List* l, size_t n) {
|
|
|
if(n > l->capacity) {
|
|
|
- setSize(l, n);
|
|
|
+ iSetListSize(l, n);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -44,13 +44,13 @@ void addLastListData(List* l) {
|
|
|
}
|
|
|
|
|
|
void* addEmptyListData(List* l) {
|
|
|
- ensureCapacity(l);
|
|
|
- return getPointer(l, l->length++);
|
|
|
+ iEnsureListCapacity(l);
|
|
|
+ return iGetListPointer(l, l->length++);
|
|
|
}
|
|
|
|
|
|
void* getListIndex(const List* l, size_t index) {
|
|
|
assert(index < l->length);
|
|
|
- return getPointer(l, index);
|
|
|
+ return iGetListPointer(l, index);
|
|
|
}
|
|
|
|
|
|
void* getListLast(const List* l) {
|
|
@@ -65,7 +65,8 @@ void removeListIndexBySwap(List* l, size_t index) {
|
|
|
assert(index < l->length);
|
|
|
size_t length = l->length - 1;
|
|
|
if(index != length) {
|
|
|
- memcpy(getPointer(l, index), getPointer(l, length), l->dataSize);
|
|
|
+ memcpy(iGetListPointer(l, index), iGetListPointer(l, length),
|
|
|
+ l->dataSize);
|
|
|
}
|
|
|
l->length = length;
|
|
|
}
|
|
@@ -73,7 +74,7 @@ void removeListIndexBySwap(List* l, size_t index) {
|
|
|
void removeListIndex(List* l, size_t index) {
|
|
|
assert(index < l->length);
|
|
|
l->length--;
|
|
|
- char* p = getPointer(l, index);
|
|
|
+ char* p = iGetListPointer(l, index);
|
|
|
char* end = getListEnd(l);
|
|
|
while(p != end) {
|
|
|
*p = *(p + l->dataSize);
|
|
@@ -90,5 +91,5 @@ void* getListStart(const List* l) {
|
|
|
}
|
|
|
|
|
|
void* getListEnd(const List* l) {
|
|
|
- return getPointer(l, l->length);
|
|
|
+ return iGetListPointer(l, l->length);
|
|
|
}
|