mirror of
https://github.com/zeldaret/ss
synced 2026-07-08 22:04:41 -04:00
Link d2d (#145)
This commit is contained in:
+18
-14
@@ -44,23 +44,27 @@ struct SizedString {
|
||||
|
||||
void operator+=(const char *src) {
|
||||
if (src != nullptr) {
|
||||
size_t destLen = strlen(mChars);
|
||||
size_t copyLen = strlen(src);
|
||||
|
||||
// Make sure copy length isnt more than destination length
|
||||
if (destLen + copyLen + 1 >= Size) {
|
||||
size_t tmpLen = Size - destLen;
|
||||
copyLen = tmpLen - 1;
|
||||
}
|
||||
|
||||
strncpy(mChars + destLen, src, copyLen);
|
||||
|
||||
// make sure string is null terminated
|
||||
size_t offset = destLen + copyLen;
|
||||
mChars[offset] = '\0';
|
||||
append(src);
|
||||
}
|
||||
}
|
||||
|
||||
void append(const char *src) {
|
||||
size_t destLen = strlen(mChars);
|
||||
size_t copyLen = strlen(src);
|
||||
|
||||
// Make sure copy length isnt more than destination length
|
||||
if (destLen + copyLen + 1 >= Size) {
|
||||
size_t tmpLen = Size - destLen;
|
||||
copyLen = tmpLen - 1;
|
||||
}
|
||||
|
||||
strncpy(mChars + destLen, src, copyLen);
|
||||
|
||||
// make sure string is null terminated
|
||||
size_t offset = destLen + copyLen;
|
||||
mChars[offset] = '\0';
|
||||
}
|
||||
|
||||
bool operator==(const char *other) const {
|
||||
return strequals(mChars, other);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user