aboutsummaryrefslogtreecommitdiff
path: root/src/types/str.c
diff options
context:
space:
mode:
authorame <[email protected]>2025-08-12 21:54:57 -0500
committerame <[email protected]>2025-08-12 21:54:57 -0500
commit432f7792d12dadc3adb605c018176bbc7359b503 (patch)
treefac1e35fd470e1c6b3a3bdeb99daf1098b43b64e /src/types/str.c
parent5666cbf8830c8b26337eb92f4da434d0d2242dc2 (diff)
support percent encoding
Diffstat (limited to 'src/types/str.c')
-rw-r--r--src/types/str.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/types/str.c b/src/types/str.c
index 0c8d63a..e1818a2 100644
--- a/src/types/str.c
+++ b/src/types/str.c
@@ -16,6 +16,19 @@ str* str_initl(const char* init, size_t len){
return s;
}
+str* str_initfl(const char* init, size_t len){
+
+ str* s = malloc(sizeof * s);
+ s->_bytes = len + 1 + alloc_buffer;
+ s->c = malloc(s->_bytes);
+ if(s->c == NULL) p_fatal("failed to allocate string\n");
+ s->len = len ;
+
+ memcpy(s->c, init, (len) * sizeof * init);
+ s->c[len] = '\0';
+ return s;
+}
+
str* str_init(const char* init){
return str_initl(init, strlen(init));
}