mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
31 lines
542 B
C++
31 lines
542 B
C++
#include "bc/string/Append.hpp"
|
|
#include <cstring>
|
|
|
|
namespace Blizzard {
|
|
namespace String {
|
|
|
|
int32_t Append(char* dst, const char* src, uint32_t count) {
|
|
if (count == 0 || dst == nullptr) {
|
|
return 0;
|
|
}
|
|
|
|
auto dstend = dst + count;
|
|
while (dst < dstend && *dst) {
|
|
dst++;
|
|
}
|
|
if (dstend <= dst) {
|
|
return 0;
|
|
}
|
|
|
|
auto dststart = dst;
|
|
|
|
while (dst < dstend && *src) {
|
|
*dst++ = *src++;
|
|
}
|
|
*dst = '\0';
|
|
|
|
return dst - dststart;
|
|
}
|
|
|
|
} // namespace String
|
|
} // namespace Blizzard
|