- Fixed several memory errors

This commit is contained in:
2025-08-20 20:57:15 -04:00
parent 037c62bf12
commit fe4c49d092
20 changed files with 463 additions and 387 deletions

View File

@@ -193,7 +193,7 @@ bool file::open(const string& p, uint8_t mode) {
}
// Attempt to open the file
_handle = fopen(p, fmode_translate(mode));
_handle = fopen(p.cstr(), fmode_translate(mode));
// Validate the file
if (_handle == nullptr) {
@@ -233,7 +233,7 @@ bool file::open(const path& p, uint8_t mode) {
}
// Attempt to open the file
_handle = fopen(p.str(), fmode_translate(mode));
_handle = fopen(p.cstr(), fmode_translate(mode));
// Validate the file
if (_handle == nullptr) {
@@ -313,7 +313,7 @@ bool file::erase() {
}
// Erase the file
remove(path.str());
remove(path.cstr());
return false;
}
@@ -335,7 +335,7 @@ bool file::rename(const cstring& str) {
}
// Attempt to open the new file
FILE* fnew = fopen(fpath.str(), "wx");
FILE* fnew = fopen(fpath.cstr(), "wx");
// Check for open failure
if (fnew == nullptr) {
@@ -395,7 +395,7 @@ bool file::rename(const cstring& str) {
fclose(_handle);
// Reopen the new file
_handle = freopen(fpath.str(), fmode_translate(_mode), fnew);
_handle = freopen(fpath.cstr(), fmode_translate(_mode), fnew);
// Check for open failure
if (_handle == nullptr) {
@@ -404,7 +404,7 @@ bool file::rename(const cstring& str) {
}
// Erase the old file
remove(_path.str());
remove(_path.cstr());
// Set the new path
_path = fpath;
@@ -429,7 +429,7 @@ bool file::rename(const string& str) {
}
// Attempt to open the new file
FILE* fnew = fopen(fpath.str(), "wx");
FILE* fnew = fopen(fpath.cstr(), "wx");
// Check for open failure
if (fnew == nullptr) {
@@ -488,7 +488,7 @@ bool file::rename(const string& str) {
fclose(_handle);
// Reopen the new file
_handle = freopen(_path.str(), fmode_translate(_mode), fnew);
_handle = freopen(_path.cstr(), fmode_translate(_mode), fnew);
// Check for open failure
if (_handle == nullptr) {
@@ -518,7 +518,7 @@ bool file::rename(const path& p) {
}
// Attempt to open the new file
FILE* fnew = fopen(fpath.str(), "wx");
FILE* fnew = fopen(fpath.cstr(), "wx");
// Check for open failure
if (fnew == nullptr) {
@@ -577,7 +577,7 @@ bool file::rename(const path& p) {
fclose(_handle);
// Reopen the new file
_handle = freopen(_path.str(), fmode_translate(_mode), fnew);
_handle = freopen(_path.cstr(), fmode_translate(_mode), fnew);
// Check for open failure
if (_handle == nullptr) {
@@ -608,7 +608,7 @@ file file::copy(const cstring& str) {
}
// Attempt to open the new file
FILE* fnew = fopen(fpath.str(), "wx");
FILE* fnew = fopen(fpath.cstr(), "wx");
// Check for open failure
if (fnew == nullptr) {
@@ -698,7 +698,7 @@ file file::copy(const string& str) {
}
// Attempt to open the new file
FILE* fnew = fopen(fpath.str(), "wx");
FILE* fnew = fopen(fpath.cstr(), "wx");
// Check for open failure
if (fnew == nullptr) {
@@ -789,7 +789,7 @@ file file::copy(const path& p) {
}
// Attempt to open the new file
FILE* fnew = fopen(fpath.str(), "wx");
FILE* fnew = fopen(fpath.cstr(), "wx");
// Check for open failure
if (fnew == nullptr) {
@@ -989,7 +989,7 @@ wstring file::getwline() {
// Check if there is a file
if (_handle == nullptr) {
return 0;
return _wstring{ L"" };
}
// Read the next line;