summaryrefslogtreecommitdiff
path: root/src/shared.c
diff options
context:
space:
mode:
author@syxhe <https://t.me/syxhe>2025-01-06 21:04:27 -0600
committer@syxhe <https://t.me/syxhe>2025-01-06 21:04:27 -0600
commit227bc3560762ae770564fcd8bad36b334696bb0b (patch)
tree4bbc6ffea7036e979a701b7107ab1ef41b97e55d /src/shared.c
parentf8e94a1179633799579a09dce1841f41e3b73f05 (diff)
sdptiny
Diffstat (limited to 'src/shared.c')
-rw-r--r--src/shared.c26
1 files changed, 0 insertions, 26 deletions
diff --git a/src/shared.c b/src/shared.c
index 0c7c8e2..2beaeb8 100644
--- a/src/shared.c
+++ b/src/shared.c
@@ -34,29 +34,3 @@ void* xreallocarray(void *ptr, size_t nmemb, size_t size) {
34 34
35 return mem; 35 return mem;
36} 36}
37
38int vsaprintf(char **str, const char *format, va_list ap) {
39 va_list ap2;
40 va_copy(ap2, ap);
41
42 int length = vsnprintf(NULL, 0, format, ap2) + 1; // + 1 because sprintf does not count the null byte
43 char *temp = reallocarray(*str, length, sizeof(char));
44 if(temp == NULL)
45 return -1;
46
47 int ret = vsnprintf(temp, length, format, ap);
48 *str = temp;
49
50 va_end(ap2);
51 return ret;
52}
53
54int saprintf(char **str, const char *format, ...) {
55 va_list ap;
56 va_start(ap, format);
57
58 int ret = vsaprintf(str, format, ap);
59
60 va_end(ap);
61 return ret;
62} \ No newline at end of file