fix(heap): Fix HeapAllocator class
This commit is contained in:
@@ -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)));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -39,6 +39,6 @@ namespace kcp {
|
||||
|
||||
cstringstream& operator<<(base nb);
|
||||
|
||||
const char* cstr();
|
||||
const char* c_str();
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user