|
|
|
[PATCH 15/17] include: add asprintf wrapper | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
include/xalloc.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/xalloc.h b/include/xalloc.h
index feeb114..8c22ff7 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -63,4 +63,15 @@ static inline char *xstrdup(const char *str)
return ret;
}
+static inline int xasprintf(char **strp, char *fmt, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, fmt);
+ ret = vasprintf(&(*strp), fmt, args);
+ va_end(args);
+ if (ret < 0)
+ err(XALLOC_EXIT_CODE, "cannot allocate string");
+ return ret;
+}
#endif
--
1.7.9.2
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Site Home] [Netdev] [Ethernet Bridging] [Linux Wireless] [Kernel Newbies] [Memory] [Security] [Linux for Hams] [Netfilter] [Bugtraq] [Rubini] [Photo] [Yosemite] [Yosemite News] [MIPS Linux] [ARM Linux] [Linux RAID] [Linux Admin] [Samba] [Video 4 Linux] [Linux Resources]