fix(heap): Fix HeapAllocator class

This commit is contained in:
Daniel Hammer
2025-04-15 20:45:34 +02:00
parent 2e45efe855
commit 35cf3f7c80
5 changed files with 20 additions and 17 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ namespace kcp {
do {
if (*str == delimiter || *str == '\0') {
auto cstr = current_stream.cstr();
auto cstr = current_stream.c_str();
auto cstr_len = Lib::strlen(cstr);
result.push_back((const char*)Memory::g_heap->Request(sizeof(char) * (cstr_len + 1)));
+3 -3
View File
@@ -23,9 +23,9 @@ kcp::cstringstream::~cstringstream()
kcp::cstringstream& kcp::cstringstream::operator<<(char c) {
this->string = (char *)Memory::g_heap->Realloc((void *)this->string, this->size + 2);
if (!this->string)
if (this->string == nullptr)
{
kerr << "Streaming failed due to failed allocation" << Kt::newline;
kerr << "kcp::cstringstream: Streaming failed due to failed allocation" << Kt::newline;
return *this;
}
@@ -85,6 +85,6 @@ kcp::cstringstream& kcp::cstringstream::operator<<(base nb)
return *this;
}
const char* kcp::cstringstream::cstr() {
const char* kcp::cstringstream::c_str() {
return this->string;
}
+1 -1
View File
@@ -39,6 +39,6 @@ namespace kcp {
cstringstream& operator<<(base nb);
const char* cstr();
const char* c_str();
};
};