Add str_cat func for concat 2 strings.
Signed-off-by: Vadim Kochan <[email protected]>
---
str.c | 17 +++++++++++++++++
str.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/str.c b/str.c
index f4cb099..e838466 100644
--- a/str.c
+++ b/str.c
@@ -109,3 +109,20 @@ char *argv2str(int startind, int argc, char **argv)
return str;
}
+
+char *str_cat(char *to, char *from)
+{
+ size_t from_len;
+ size_t to_len;
+
+ if (!from)
+ return to;
+
+ to_len = to ? strlen(to) : 0;
+ from_len = strlen(from);
+
+ to = xrealloc(to, to_len + from_len + 1);
+ slprintf(to + to_len, from_len + 1, "%s", from);
+
+ return to;
+}
diff --git a/str.h b/str.h
index 7d078da..4b4ed22 100644
--- a/str.h
+++ b/str.h
@@ -9,5 +9,6 @@ extern int slprintf_nocheck(char *dst, size_t size, const char
*fmt, ...);
extern char *strtrim_right(char *p, char c);
extern noinline void *xmemset(void *s, int c, size_t n);
extern char *argv2str(int startind, int argc, char **argv);
+extern char *str_cat(char *to, char *from);
#endif /* STR_H */
--
2.6.2
--
You received this message because you are subscribed to the Google Groups
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.