summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qstd/str.c6
-rw-r--r--qstd/str.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/qstd/str.c b/qstd/str.c
index 5dd97c4..5461880 100644
--- a/qstd/str.c
+++ b/qstd/str.c
@@ -58,3 +58,9 @@ char* dup_string(Arena* a, const char* s) {
return d;
}
+char* dup_stringh(struct Heap* h, const char* s) {
+ int size = string_len(s) + 1;
+ char* d = heap_alloc_aligned(h, size, 1);
+ string_copy(d, s);
+ return d;
+}
diff --git a/qstd/str.h b/qstd/str.h
index 011fc27..8158554 100644
--- a/qstd/str.h
+++ b/qstd/str.h
@@ -5,6 +5,7 @@
#include <stdint.h>
struct Arena;
+struct Heap;
uint64_t fnv1a64(uint8_t* buf, size_t size);
uint64_t fnv1a64_2(uint64_t h, uint8_t* buf, size_t size);
@@ -14,5 +15,6 @@ int string_equal(const char* a, const char* b);
int string_copy(char* dst, const char* src);
int string_len(const char* s);
char* dup_string(struct Arena* a, const char* s);
+char* dup_stringh(struct Heap* h, const char* s);
#endif