Concatinate String fuer String Repository

This commit is contained in:
Ronja 2022-12-16 12:46:08 +01:00
parent 15a0b77960
commit 32a3538bcb
2 changed files with 19 additions and 0 deletions

View File

@ -84,6 +84,20 @@ void StringRepository::releaseString(StringHandle)
// do nothing
}
StringHandle StringRepository::concatenateString(StringHandle a, StringHandle b)
{
ZoneScoped;
const char* texta = getString(a);
const char* textb = getString(b);
size_t length = strlen(texta) + strlen(textb);
char* textc = (char*)malloc(sizeof(char)*(length+1));
snprintf(textc, length + 1, "%s%s", texta, textb);
nt_string_handle c = internString(textc);
free(textc);
return c;
}
void StringRepository::freeAll()
{
ZoneScoped;

View File

@ -41,6 +41,11 @@ public:
/// @brief Frees a string
void releaseString(StringHandle handle);
/// @brief Adds a string to the string repository
/// @param a the first string
/// @param b the second string
StringHandle concatenateString(StringHandle a, StringHandle b);
/// @brief Frees all strings inside the repository
void freeAll();