diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-11-19 15:31:47 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-11-19 15:31:47 +0000 |
| commit | 303f428e78cf44f10032e55a69d5d5cd00f5d715 (patch) | |
| tree | ece80fc79cefc42bc63c8de409bca88b791bca08 /runtime/src/strings.c | |
| parent | c690c58c4e4c88f5b1a0d29a49a5f941f051b372 (diff) | |
Split out strings module in runtime
Diffstat (limited to 'runtime/src/strings.c')
| -rw-r--r-- | runtime/src/strings.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/src/strings.c b/runtime/src/strings.c new file mode 100644 index 00000000..9a81a4fd --- /dev/null +++ b/runtime/src/strings.c @@ -0,0 +1,21 @@ +#include "./shed.h" + +ShedString shed__runtime__string_alloc(ShedStringLength length) { + return shed__runtime__alloc(sizeof(ShedStringLength) + length); +} + +ShedString shed__runtime__string_add(ShedString left, ShedString right) { + ShedStringLength length = left->length + right->length; + ShedString string = shed__runtime__string_alloc(length); + string->length = length; + + for(ShedStringLength i = 0; i < left->length; i++) { + string->data[i] = left->data[i]; + } + + for(ShedStringLength i = 0; i < right->length; i++) { + string->data[left->length + i] = right->data[i]; + } + + return string; +} |
