--- a/project_files/frontlib/util/util.c Tue Jun 19 21:20:08 2012 +0200
+++ b/project_files/frontlib/util/util.c Thu Jun 21 21:32:12 2012 +0200
@@ -36,6 +36,28 @@
return result;
}
+char *flib_join(char **parts, int partCount, const char *delimiter) {
+ size_t totalSize = 1;
+ size_t delimLen = strlen(delimiter);
+ for(int i=0; i<partCount; i++) {
+ totalSize += strlen(parts[i]) + delimLen;
+ }
+
+ char *result = flib_malloc(totalSize);
+ if(result) {
+ size_t outpos = 0;
+ for(int i=0; i<partCount; i++) {
+ if(i>0) {
+ strcpy(result+outpos, delimiter);
+ outpos += delimLen;
+ }
+ strcpy(result+outpos, parts[i]);
+ outpos += strlen(parts[i]);
+ }
+ }
+ return result;
+}
+
char *flib_strdupnull(const char *str) {
if(!str) {
return NULL;