Minor refactor

This commit is contained in:
MihailRis
2024-01-03 20:42:26 +03:00
parent 0d36f52bdd
commit 2ad115a2a8
9 changed files with 19 additions and 20 deletions
+4 -4
View File
@@ -3,6 +3,7 @@
#include <iostream>
#include <fstream>
#include <cstring>
#include <memory>
#include <type_traits>
#ifdef __APPLE__
@@ -192,13 +193,12 @@ char* load_wav(const std::string& filename,
return nullptr;
}
char* data = new char[size];
std::unique_ptr<char[]> data (new char[size]);
try {
in.read(data, size);
return data;
in.read(data.get(), size);
return data.release();
}
catch (const std::exception&) {
delete[] data;
std::cerr << "ERROR: Could not load wav data of \"" << filename << "\"" << std::endl;
return nullptr;
}