Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MeltedForge/src/mf/core/mfarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ MFArray mfArrayCreate(u64 capacity, u64 elementSize) {
array.elementSize = elementSize;
array.capacity = capacity;

array.data = malloc(elementSize * capacity);
memset(array.data, 0, elementSize * capacity);
array.data = calloc(capacity, elementSize);
MF_PANIC_IF(array.data == mfnull, mfGetLogger(), "Array allocation failed or size overflowed!");

array.init = true;
return array;
Expand Down Expand Up @@ -56,7 +56,7 @@ void mfArrayResize(MFArray* array, u64 newCapacity) {
void mfArrayInsertAt(MFArray* array, u64 index, void* element) {
MF_PANIC_IF(array == mfnull, mfGetLogger(), "The array provided shouldn't be 0!");
MF_PANIC_IF(!array->init, mfGetLogger(), "The array provided isn't initialised!");
MF_DO_IF(index >= array->len, {
MF_DO_IF(index > array->len, {
slogLogMsg(mfGetLogger(), SLOG_SEVERITY_WARN, "The index provided to MFArray is invalid!");
return;
});
Expand Down