#15 Fixed some of the worst memory leaks

This commit is contained in:
2022-08-22 20:51:09 +01:00
parent b675c4c1bd
commit 08e2adab50
8 changed files with 22 additions and 5 deletions

View File

@@ -5,7 +5,12 @@
#include <stdio.h>
#include <stdlib.h>
static int allocatedMemoryCount = 0;
void* reallocate(void* pointer, size_t oldSize, size_t newSize) {
allocatedMemoryCount -= oldSize;
allocatedMemoryCount += newSize;
if (newSize == 0) {
free(pointer);
@@ -22,3 +27,6 @@ void* reallocate(void* pointer, size_t oldSize, size_t newSize) {
return mem;
}
int getAllocatedMemoryCount() {
return allocatedMemoryCount;
}