Add cfw_string_append().

This commit is contained in:
Jonathan Schleifer 2012-04-08 21:19:56 +02:00
parent d957ec53ea
commit 0915874505
3 changed files with 32 additions and 2 deletions

View file

@ -131,6 +131,23 @@ cfw_string_set(CFWString *str, const char *cstr)
return true;
}
bool
cfw_string_append(CFWString *str, CFWString *append)
{
char *new;
if ((new = realloc(str->cstr, str->len + append->len + 1)) == NULL)
return false;
memcpy(new + str->len, append->cstr, append->len);
new[str->len + append->len] = 0;
str->cstr = new;
str->len += append->len;
return true;
}
static CFWClass class = {
.name = "CFWString",
.size = sizeof(CFWString),

View file

@ -34,5 +34,6 @@ extern CFWClass *cfw_string;
extern const char* cfw_string_c(CFWString*);
extern size_t cfw_string_len(CFWString*);
extern bool cfw_string_set(CFWString*, const char*);
extern bool cfw_string_append(CFWString*, CFWString*);
#endif