diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-02-11 21:29:15 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-02-11 21:29:15 +0000 |
| commit | a01ee103f9bc0c6defe9ce8cd85651f19f7127bd (patch) | |
| tree | 8634fd33dde74b4aab1519e1b61bc3343d99606f /runtime/src/shed/strings.c | |
| parent | 3d4e3f4a54d128a2a280b5adc921f3d95fb963bb (diff) | |
Create separate lib for patio runtime
Diffstat (limited to 'runtime/src/shed/strings.c')
| -rw-r--r-- | runtime/src/shed/strings.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/src/shed/strings.c b/runtime/src/shed/strings.c new file mode 100644 index 00000000..8ef25433 --- /dev/null +++ b/runtime/src/shed/strings.c @@ -0,0 +1,22 @@ +#include "./gc.h" +#include "./strings.h" + +ShedString shed__runtime__string_alloc(ShedStringLength length) { + return shed__runtime__gc_alloc(sizeof(struct ShedString) + length, 0); +} + +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; +} |
