aboutsummaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
Diffstat (limited to 'src/types')
-rw-r--r--src/types/str.c12
-rw-r--r--src/types/str.h8
2 files changed, 8 insertions, 12 deletions
diff --git a/src/types/str.c b/src/types/str.c
index 364a02f..0378285 100644
--- a/src/types/str.c
+++ b/src/types/str.c
@@ -4,11 +4,7 @@
#define alloc_buffer 64
-str* str_initl(char* init, size_t len){
- if(init == NULL){
- char cc = '\0';
- init = &cc;
- }
+str* str_initl(const char* init, size_t len){
str* s = malloc(sizeof * s);
s->_bytes = len + 1 + alloc_buffer;
@@ -20,7 +16,7 @@ str* str_initl(char* init, size_t len){
return s;
}
-str* str_init(char* init){
+str* str_init(const char* init){
return str_initl(init, strlen(init));
}
@@ -29,14 +25,14 @@ void str_free(str* s){
return free(s);
}
-void str_push(str* s, char* insert){
+void str_push(str* s, const char* insert){
s->len += strlen(insert);
if(s->len + 1 >= s->_bytes)
s->c = realloc(s->c, s->_bytes = s->len + 1 + alloc_buffer);
strcat(s->c, insert);
}
-void str_pushl(str* s, char* insert, size_t l){
+void str_pushl(str* s, const char* insert, size_t l){
if(s->len + l >= s->_bytes)
s->c = realloc(s->c, s->_bytes = s->len + l + alloc_buffer);
//strcat(s->c, insert);
diff --git a/src/types/str.h b/src/types/str.h
index 1f50eab..86490cc 100644
--- a/src/types/str.h
+++ b/src/types/str.h
@@ -11,11 +11,11 @@ typedef struct {
char* c;
} str;
-str* str_initl(char*, size_t len);
-str* str_init(char*);
+str* str_initl(const char*, size_t len);
+str* str_init(const char*);
void str_free(str*);
-void str_push(str*, char*);
-void str_pushl(str*, char*, size_t);
+void str_push(str*, const char*);
+void str_pushl(str*, const char*, size_t);
void str_clear(str*);
void str_popf(str*, int);
void str_popb(str*, int);