- 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;

View File

@@ -46,7 +46,7 @@ path path::current() {
}
path path::current(const path& path) {
if (chdir(path._str)) {
if (chdir(path._str.cstr())) {
return fennec::path("");
}
return current();

View File

@@ -29,7 +29,7 @@ static constexpr void insert_driver(list<platform::driver<CtorT>>& drvrs, CtorT
iter_t it = drvrs.begin();
while (it != drvrs.end()) {
if (priority > it->priority) {
if (priority >= it->priority) {
break;
}
}

View File

@@ -38,10 +38,10 @@ void unix_platform::unload_object(shared_object* obj) {
platform::symbol unix_platform::find_symbol(shared_object* obj, const cstring& name) {
string _name = name;
void* symbol = dlsym(obj, _name);
void* symbol = dlsym(obj, _name.cstr());
if (symbol == nullptr) {
_name = '_' + _name;
symbol = dlsym(obj, _name);
symbol = dlsym(obj, _name.cstr());
}
return symbol;
}