mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
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.
This commit is contained in:
parent
3d091f39bf
commit
76bf0eb30c
2 changed files with 0 additions and 44 deletions
|
@ -31,7 +31,6 @@ namespace Sortix {
|
||||||
namespace String {
|
namespace String {
|
||||||
|
|
||||||
char* Clone(const char* Source);
|
char* Clone(const char* Source);
|
||||||
char* Combine(size_t NumParameters, ...);
|
|
||||||
char* Substring(const char* src, size_t offset, size_t length);
|
char* Substring(const char* src, size_t offset, size_t length);
|
||||||
bool StartsWith(const char* Haystack, const char* Needle);
|
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;
|
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 String
|
||||||
} // namespace Sortix
|
} // namespace Sortix
|
||||||
|
|
Loading…
Reference in a new issue