diff options
| author | Carson Fleming <[email protected]> | 2026-02-14 02:53:37 -0500 |
|---|---|---|
| committer | Carson Fleming <[email protected]> | 2026-02-14 02:53:37 -0500 |
| commit | 9ef0abf7ab5266f6b58c0e55bbe9dd9038bc7f6e (patch) | |
| tree | 54abfa548d7aae56c1ace1a72bce8581570b5fd2 /str.h | |
| parent | 1a08245d480b8a18fcbc80efd8602cdb90d6ed5e (diff) | |
| download | safec-9ef0abf7ab5266f6b58c0e55bbe9dd9038bc7f6e.tar.gz | |
more like dangerousc.org atp
Diffstat (limited to 'str.h')
| -rw-r--r-- | str.h | 27 |
1 files changed, 11 insertions, 16 deletions
@@ -7,31 +7,26 @@ typedef struct { char* __data; } str_t; -// TODO: heap-allocing the pointer is stupid just return a value -// should just heap-alloc __data - -char* str_at(const str_t str, size_t idx); -str_t str_slice(const str_t str, size_t start, size_t length); -int str_cmp(const str_t s1, const str_t s2); +char* str_at(const str_t* str, size_t idx); +str_t str_slice(const str_t* str, size_t start, size_t length); +int str_cmp(const str_t* s1, const str_t* s2); /* not found = -1 */ -ssize_t str_indexof(const str_t str, char c); -ssize_t str_rindexof(const str_t str, char c); +ssize_t str_indexof(const str_t* str, char c); +ssize_t str_rindexof(const str_t* str, char c); -str_t str_heap_dup(const str_t str); -str_t str_heap_cat(const str_t s1, const str_t s2); +str_t str_heap_dup(const str_t* str); +str_t str_heap_cat(const str_t* s1, const str_t* s2); /* TODO: implement string.h functions for this new string construct */ /* `dst` will be overwritten with the contents of `src` */ void str_to_c_str(char* dst, size_t dst_size, const str_t* src); -char* str_to_heap_c_str(const str_t str); - -str_t str_init(char* data, size_t length); +char* str_to_heap_c_str(const str_t* str); str_t str_heap_alloc(size_t length); -str_t str_heap_alloc_iv(const char* c_str); -str_t str_heap_alloc_iv_slice(const char* c_str, size_t start, size_t length); -void str_heap_destroy(str_t str); +str_t str_heap_init(const char* c_str, size_t length); +str_t str_heap_init_slice(const char* c_str, size_t start, size_t length); +void str_heap_destroy(str_t* str); #endif |
