[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Google
  Web www.spinics.net

[PATCH 1/2] FcStrPlusPlus: new helper function



This is like FcStrPlus, except that it takes an arbitrary number of
additional strings to append.

Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx>
---
 fontconfig/fontconfig.h |    3 +++
 src/fcstr.c             |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index db26b97..465ffa1 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -860,6 +860,9 @@ FcStrCopyFilename (const FcChar8 *s);
     
 FcPublic FcChar8 *
 FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
+
+FcPublic FcChar8 *
+FcStrPlusPlus (const FcChar8 *s1, ...);
     
 FcPublic void
 FcStrFree (FcChar8 *s);
diff --git a/src/fcstr.c b/src/fcstr.c
index b712e5d..6dfb1ef 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -63,6 +63,38 @@ FcStrPlus (const FcChar8 *s1, const FcChar8 *s2)
     return s;
 }
 
+FcChar8 *
+FcStrPlusPlus (const FcChar8 *s1, ...)
+{
+    va_list ap;
+    const FcChar8 *arg;
+    FcChar8 *s;
+    int l;
+    int al;
+
+    va_start (ap, s1);
+    arg = s1;
+    s = NULL;
+    l = 0;
+    do {
+	if (!arg)
+	    break;
+	al = strlen ((char *) arg);
+	s = realloc (s, l + al + 1);
+	if (!s)
+	    return 0;
+	memcpy (s + l, arg, al + 1);
+	l += al;
+
+	arg = va_arg (ap, const FcChar8 *);
+    } while (1);
+    va_end (ap);
+
+    if (l)
+	FcMemAlloc (FC_MEM_STRING, l + 1);
+    return s;
+}
+
 void
 FcStrFree (FcChar8 *s)
 {
-- 
1.7.6.1

_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig


[Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Legacy]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux