aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2018-11-24 14:47:54 -0600
committerDavid Gibson <david@gibson.dropbear.id.au>2018-11-25 18:21:48 +1100
commita1eff70c02cfd3a6263adfd6aab25290211f31aa (patch)
tree25cd74143b5984e49f5f22208e39fd6d8bb97ff4 /util.h
parent82a52ce4573b7cd0039786f65b280fb99431fe5d (diff)
downloaddtc-a1eff70c02cfd3a6263adfd6aab25290211f31aa.zip
dtc-a1eff70c02cfd3a6263adfd6aab25290211f31aa.tar.gz
dtc-a1eff70c02cfd3a6263adfd6aab25290211f31aa.tar.bz2
util: Add xa{v}sprintf_append functions
Add variadic and va_list functions, xa{v}sprintf, which appends a formatted string to an existing string and re-allocate the string buffer if necessary. xasprintf becomes just a special case of xasprintf_append with a NULL starting string. Rather than looping to get a big enough buffer, simply the implementation by assuming we have a C99 compliant vsnprintf implementation to return the necessary size. A side effect is glibc 2.0 support is dropped which seems unnecessary. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'util.h')
-rw-r--r--util.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/util.h b/util.h
index f6cea82..7658781 100644
--- a/util.h
+++ b/util.h
@@ -72,6 +72,8 @@ static inline void *xrealloc(void *p, size_t len)
extern char *xstrdup(const char *s);
extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...);
+extern int PRINTF(2, 3) xasprintf_append(char **strp, const char *fmt, ...);
+extern int xavsprintf_append(char **strp, const char *fmt, va_list ap);
extern char *join_path(const char *path, const char *name);
/**