diff options
author | Test_User <hax@andrewyu.org> | 2024-06-14 11:17:21 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2024-06-14 11:17:21 -0400 |
commit | 1328829eef7a1beb6e7558f60cbe9d1c3935d97a (patch) | |
tree | dad162b85ef951027fe800858ba95af19f78385a /haxstring_utils.c | |
parent | 80bd818208729b24262141b9068c427f9d8a097a (diff) | |
download | haxircd-1328829eef7a1beb6e7558f60cbe9d1c3935d97a.tar.gz haxircd-1328829eef7a1beb6e7558f60cbe9d1c3935d97a.zip |
Psuedoclients
Diffstat (limited to 'haxstring_utils.c')
-rw-r--r-- | haxstring_utils.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/haxstring_utils.c b/haxstring_utils.c index 2a7ed02..82be667 100644 --- a/haxstring_utils.c +++ b/haxstring_utils.c @@ -109,3 +109,22 @@ int str_clone(struct string *dest, struct string source) { return 0; } + +int str_combine(struct string *dest, size_t count, struct string *sources) { + size_t len = 0; + for (size_t i = 0; i < count; i++) + len += sources[i].len; + + dest->data = malloc(len); + if (!dest->data && len != 0) + return 1; + dest->len = len; + + size_t offset = 0; + for (size_t i = 0; i < count; i++) { + memcpy(&(dest->data[offset]), sources[i].data, sources[i].len); + offset += sources[i].len; + } + + return 0; +} |