diff options
author | David Robillard <d@drobilla.net> | 2006-07-26 18:53:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-07-26 18:53:15 +0000 |
commit | f988795439be205e96f71563b8de37b3eb399c55 (patch) | |
tree | a765305b545a7e93c7c49c0ee4a00b278b0d4d79 /src/util.c | |
parent | a15486a0151251ddc7805604a08580fa8279efaa (diff) | |
download | lilv-f988795439be205e96f71563b8de37b3eb399c55.tar.gz lilv-f988795439be205e96f71563b8de37b3eb399c55.tar.bz2 lilv-f988795439be205e96f71563b8de37b3eb399c55.zip |
Removed vstrjoin
git-svn-id: http://svn.drobilla.net/lad/libslv2@105 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 49 |
1 files changed, 25 insertions, 24 deletions
@@ -42,36 +42,37 @@ strappend(char** dst, const char* suffix) char* strjoin(const char* first, ...) { - va_list args_list; - va_start(args_list, first); - - char* result = vstrjoin(first, args_list); - - va_end(args_list); - - return result; -} - - -char* -vstrjoin(const char* first, va_list args_list) -{ - // FIXME: this is horribly, awfully, disgracefully slow. - // so I'm lazy. - - const char* arg = NULL; - char* result = strdup(first); + size_t len = strlen(first); + char* result = NULL; + va_list args; + + va_start(args, first); + while (1) { + const char* const s = va_arg(args, const char *); + if (s == NULL) + break; + len += strlen(s); + } + va_end(args); + + result = malloc(len + 1); + if (!result) + return NULL; - while ((arg = va_arg(args_list, const char*)) != NULL) - strappend(&result, arg); - - //va_end(args_list); + strcpy(result, first); + va_start(args, first); + while (1) { + const char* const s = va_arg(args, const char *); + if (s == NULL) + break; + strcat(result, s); + } + va_end(args); return result; } - /** Convert a URL to a local filesystem path (ie by chopping off the * leading "file://". * |