Skip to content

Commit

Permalink
Fix memory freeing issue on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
louist103 committed Nov 22, 2024
1 parent 3e181b7 commit 56ff59f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion utils/filebox.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void FillFileQueue(T& dest, char* mBasePath, ExtCheckCallback cb) {
size_t s2 = strlen(mBasePath);
size_t sizeToAlloc = s1 + s2 + 2;

char* fullPath = (char*)operator new(sizeToAlloc, std::align_val_t(2));
char* fullPath = (char*)operator new[](sizeToAlloc, std::align_val_t(2));
snprintf(fullPath, sizeToAlloc, "%s\\%s", mBasePath, ffd.cFileName);
dest.push_back(fullPath);
}
Expand Down
4 changes: 2 additions & 2 deletions windows/CustomStreamedAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ CustomStreamedAudioWindow::CustomStreamedAudioWindow() {
static void ClearFileQueue(std::vector<char*>* fileQueue) {
for (auto f : *fileQueue) {
// The lowest bit of the path is set to 1 if the file has been processed. We need to undo that to delete it.
uintptr_t origPtr = (uintptr_t)f & (UINTPTR_MAX & (~1));
operator delete[]((char*)(origPtr));
uintptr_t origPtr = (uintptr_t)f & (UINTPTR_MAX & (~(uintptr_t)1));
operator delete[]((void*)origPtr, std::align_val_t(2));
}
fileQueue->clear();
}
Expand Down

0 comments on commit 56ff59f

Please sign in to comment.