diff options
author | wrmr | 2024-11-09 02:04:33 -0500 |
---|---|---|
committer | wrmr | 2024-11-09 02:04:33 -0500 |
commit | 38987f3f5a3919ac81ba419e05ac8610c269faff (patch) | |
tree | dc76c691f0e7d8385224ede708b9390b50b68dff /str.h | |
parent | 12d5d0df5c4b958bbb5cc339a9e556c50136a974 (diff) |
rename buf_t to str_t, and consolidate str.c/h with strv.c/h
Diffstat (limited to 'str.h')
-rw-r--r-- | str.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/str.h b/str.h new file mode 100644 index 0000000..fe56d98 --- /dev/null +++ b/str.h @@ -0,0 +1,30 @@ +#ifndef BUF_H +#define BUF_H + +#include <stddef.h> + +/* string views */ + +typedef struct { + const char *s; + size_t n; +} strv_t; + +strv_t strv(const char *s); +int strv_split(strv_t *src, int chr, strv_t *dest); + +/* strings */ + +typedef struct buf { + size_t sz, cap; + char *buf; +} str_t; + +void str_init(str_t *, size_t); +void str_grow(str_t *, size_t); +void str_free(str_t *); + +void str_cat(str_t *b, strv_t s); +void str_catc(str_t *b, char c); + +#endif |