common FEATURE ly_strcat() to concatenate strings
diff --git a/src/common.c b/src/common.c
index 3c36baa..4938325 100644
--- a/src/common.c
+++ b/src/common.c
@@ -15,9 +15,10 @@
#include "common.h"
#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
#include <ctype.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
@@ -309,6 +310,32 @@
}
LY_ERR
+ly_strcat(char **dest, const char *format, ...)
+{
+ va_list fp;
+ char *addition = NULL;
+ size_t len;
+
+ va_start(fp, format);
+ len = vasprintf(&addition, format, fp);
+ len += (*dest ? strlen(*dest) : 0) + 1;
+
+ if (*dest) {
+ *dest = ly_realloc(*dest, len);
+ if (!*dest) {
+ return LY_EMEM;
+ }
+ *dest = strcat(*dest, addition);
+ free(addition);
+ } else {
+ *dest = addition;
+ }
+
+ va_end(fp);
+ return LY_SUCCESS;
+}
+
+LY_ERR
ly_parse_int(const char *val_str, size_t val_len, int64_t min, int64_t max, int base, int64_t *ret)
{
char *strptr;