cfw_new() takes parameters now.
This commit is contained in:
parent
8603645700
commit
a9e4c2a8d9
6 changed files with 43 additions and 31 deletions
18
cfwstring.c
18
cfwstring.c
|
@ -36,13 +36,23 @@ struct CFWString {
|
|||
size_t len;
|
||||
};
|
||||
|
||||
static void
|
||||
ctor(void *ptr)
|
||||
static bool
|
||||
ctor(void *ptr, va_list args)
|
||||
{
|
||||
CFWString *str = ptr;
|
||||
const char *cstr = va_arg(args, const char*);
|
||||
|
||||
str->cstr = NULL;
|
||||
str->len = 0;
|
||||
if (cstr != NULL) {
|
||||
if ((str->cstr = strdup(cstr)) == NULL)
|
||||
return false;
|
||||
|
||||
str->len = strlen(cstr);
|
||||
} else {
|
||||
str->cstr = NULL;
|
||||
str->len = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue