Bug fix for mismatched allocation/deallocation calls. Memory allocated with malloc should use free (not delete) to deallocate memory.

This commit is contained in:
harry 2022-08-04 05:40:03 -04:00 committed by zeromus
parent 0c36a3575e
commit 0e9ad2f400
2 changed files with 2 additions and 2 deletions

View File

@ -90,7 +90,7 @@ public:
ptr = ::realloc(ptr,len); ptr = ::realloc(ptr,len);
return ptr; return ptr;
} }
void free(void *ptr) { static void free(void *ptr) {
::free(ptr); ::free(ptr);
} }

View File

@ -58,7 +58,7 @@ public:
Buffer(int size) { length = 0; this->size = size; data = OAKRA_Module::malloc(size); } Buffer(int size) { length = 0; this->size = size; data = OAKRA_Module::malloc(size); }
int getRemaining() { return size-length; } int getRemaining() { return size-length; }
void *data; void *data;
~Buffer() { delete data; } ~Buffer() { if (data){ OAKRA_Module::free(data); data = nullptr; } }
}; };
std::vector<Buffer*> liveBuffers; std::vector<Buffer*> liveBuffers;