diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-10 22:11:41 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-10 22:11:41 +0530 |
commit | 9a2b779bb2f5f771604c22ddd0ac6d7932b900ff (patch) | |
tree | 7886352d61b130e0b077a16a97ffa86825d09feb /src/util.c | |
parent | 6d3a1f6a1f3a92b726e55ced046c10d2936ee54f (diff) |
util: implement xstrcat
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..4863e29 --- /dev/null +++ b/src/util.c @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <util.h> + +void +xstrcat(char *s1, char *s2) +{ + size_t a = strlen(s1); + size_t b = strlen(s2); + size_t size_ab = a + b + 1; + + s1 = realloc(s1, size_ab); + + memcpy(s1 + a, s2, b + 1); +} |