fix(kcp, IDT, Heap, kernel): Various fixes, scrap broken memory allocator

This commit is contained in:
Daniel Hammer
2025-03-11 20:00:04 +01:00
parent b774f82625
commit cc094a9172
23 changed files with 18910 additions and 195 deletions
+42
View File
@@ -0,0 +1,42 @@
/*
* CString.cpp
* C++ string tooling
* Copyright (c) 2025 Daniel Hammer
*/
#include "CString.hpp"
#include "Stream.hpp"
#include <Libraries/Memory.hpp>
#include <Memory/Heap.hpp>
namespace kcp {
vector<const char*> splitstr(const char* str, char delimiter) {
vector<const char*> result;
cstringstream current_stream = cstringstream();
do {
if (*str == delimiter || *str == '\0') {
auto cstr = current_stream.cstr();
auto cstr_len = Lib::strlen(cstr);
result.push_back((const char*)Memory::g_heap->Request(sizeof(char) * (cstr_len + 1)));
memcpy((void*)result.at(result.size() - 1), cstr, cstr_len + 1);
if (*str == '\0') {
break;
}
current_stream = cstringstream();
str++;
continue;
}
current_stream << (char)*str;
str++;
} while (*str != '\0');
return result;
}
};