Commit 76bf0eb3 authored by Jonas Termansen's avatar Jonas Termansen

Remove String::Combine kernel function.

This function has followed me through a few projects for many years. It's
time to retire it. It's not too terribly well-written and it's mostly
replaced by the standard asprintf call. It's not even used in Sortix at the
moment.
parent 3d091f39
......@@ -31,7 +31,6 @@ namespace Sortix {
namespace String {
char* Clone(const char* Source);
char* Combine(size_t NumParameters, ...);
char* Substring(const char* src, size_t offset, size_t length);
bool StartsWith(const char* Haystack, const char* Needle);
......
......@@ -52,48 +52,5 @@ char* Substring(const char* src, size_t offset, size_t length)
return dest;
}
char* Combine(size_t NumParameters, ...)
{
va_list param_pt;
va_start(param_pt, NumParameters);
// First calculate the string length.
size_t ResultLength = 0;
const char* TMP = 0;
for ( size_t I = 0; I < NumParameters; I++ )
{
TMP = va_arg(param_pt, const char*);
if ( TMP != NULL ) { ResultLength += strlen(TMP); }
}
// Allocate a string with the desired length.
char* Result = new char[ResultLength+1];
if ( !Result ) { return NULL; }
Result[0] = 0;
va_end(param_pt);
va_start(param_pt, NumParameters);
size_t ResultOffset = 0;
for ( size_t I = 0; I < NumParameters; I++ )
{
TMP = va_arg(param_pt, const char*);
if ( TMP )
{
size_t TMPLength = strlen(TMP);
strcpy(Result + ResultOffset, TMP);
ResultOffset += TMPLength;
}
}
return Result;
}
} // namespace String
} // namespace Sortix
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment