|
|
@@ -6,8 +6,8 @@
|
|
|
#include "scufcont/scufcont.h"
|
|
|
#include "scufcont/DString.h"
|
|
|
|
|
|
-ScufContResult SCDString_alloc(SCDString* dstr, const char* str, const size_t len) {
|
|
|
- dstr->data = (char*) malloc(sizeof(char) * (len + 1));
|
|
|
+ScufContResult SCDString_alloc(SCDString *const dstr, const char *str, const size_t len) {
|
|
|
+ dstr->data = (char *) malloc(sizeof(char) * (len + 1));
|
|
|
dstr->len = len;
|
|
|
dstr->capacity = len + 1;
|
|
|
if (dstr->data == NULL) {
|
|
|
@@ -19,10 +19,10 @@ ScufContResult SCDString_alloc(SCDString* dstr, const char* str, const size_t le
|
|
|
return SCUFCONT_SUCCESS;
|
|
|
}
|
|
|
|
|
|
-ScufContResult SCDString_reserve(SCDString* dstr, const size_t new_capacity) {
|
|
|
+ScufContResult SCDString_reserve(SCDString *const dstr, const size_t new_capacity) {
|
|
|
if (dstr->capacity < new_capacity) {
|
|
|
errno = 0;
|
|
|
- dstr->data = (char*) realloc(dstr->data, sizeof(char) * new_capacity);
|
|
|
+ dstr->data = (char *) realloc(dstr->data, sizeof(char) * new_capacity);
|
|
|
if (errno != 0) {
|
|
|
return SCUFCONT_OUT_OF_MEMORY;
|
|
|
}
|
|
|
@@ -32,7 +32,7 @@ ScufContResult SCDString_reserve(SCDString* dstr, const size_t new_capacity) {
|
|
|
return SCUFCONT_SUCCESS;
|
|
|
}
|
|
|
|
|
|
-void SCDString_free(SCDString* dstr) {
|
|
|
+void SCDString_free(SCDString *const dstr) {
|
|
|
if (dstr->data != NULL) {
|
|
|
free(dstr->data);
|
|
|
dstr->data = NULL;
|
|
|
@@ -41,7 +41,7 @@ void SCDString_free(SCDString* dstr) {
|
|
|
dstr->capacity = 0;
|
|
|
}
|
|
|
|
|
|
-bool SCDString_equal(const SCDString* s1, const SCDString* s2) {
|
|
|
+bool SCDString_equal(const SCDString *const s1, const SCDString *const s2) {
|
|
|
if (s1->data == NULL || s2->data == NULL) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -59,7 +59,7 @@ bool SCDString_equal(const SCDString* s1, const SCDString* s2) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-bool SCDString_equal_c_str(const SCDString* s1, const char* s2) {
|
|
|
+bool SCDString_equal_c_str(const SCDString *const s1, const char *s2) {
|
|
|
if (s1->data == NULL || s2 == NULL) {
|
|
|
return false;
|
|
|
}
|
|
|
@@ -78,8 +78,8 @@ bool SCDString_equal_c_str(const SCDString* s1, const char* s2) {
|
|
|
}
|
|
|
|
|
|
bool SCDString_equal_next_chars_c_str(
|
|
|
- const SCDString* dstr,
|
|
|
- const char* str,
|
|
|
+ const SCDString *const dstr,
|
|
|
+ const char *str,
|
|
|
const size_t str_len,
|
|
|
size_t s
|
|
|
) {
|
|
|
@@ -98,8 +98,8 @@ bool SCDString_equal_next_chars_c_str(
|
|
|
}
|
|
|
|
|
|
ScufContResult SCDString_concat_c_str(
|
|
|
- SCDString* dstr,
|
|
|
- const char* str,
|
|
|
+ SCDString *const dstr,
|
|
|
+ const char *str,
|
|
|
const size_t str_len
|
|
|
) {
|
|
|
const size_t new_len = dstr->len + str_len;
|
|
|
@@ -118,10 +118,10 @@ ScufContResult SCDString_concat_c_str(
|
|
|
}
|
|
|
|
|
|
ScufContResult SCDString_alloc_concat_c_strs(
|
|
|
- SCDString* dstr,
|
|
|
- const char* s1,
|
|
|
+ SCDString *const dstr,
|
|
|
+ const char *s1,
|
|
|
const size_t s1_len,
|
|
|
- const char* s2,
|
|
|
+ const char *s2,
|
|
|
const size_t s2_len
|
|
|
) {
|
|
|
ScufContResult res = SCDString_alloc(dstr, s1, s1_len);
|
|
|
@@ -136,10 +136,10 @@ ScufContResult SCDString_alloc_concat_c_strs(
|
|
|
}
|
|
|
|
|
|
ScufContResult SCDString_split(
|
|
|
- const SCDString* dstr,
|
|
|
- const char* delim,
|
|
|
- SCDString** split_arr,
|
|
|
- size_t* arr_len
|
|
|
+ const SCDString *const dstr,
|
|
|
+ const char *delim,
|
|
|
+ SCDString **const split_arr,
|
|
|
+ size_t *arr_len
|
|
|
) {
|
|
|
ScufContResult ret = SCUFCONT_SUCCESS;
|
|
|
*arr_len = 0;
|
|
|
@@ -189,7 +189,7 @@ ScufContResult SCDString_split(
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-void SCDString_split_arr_free(SCDString** arr, const size_t arr_len) {
|
|
|
+void SCDString_split_arr_free(SCDString **const arr, const size_t arr_len) {
|
|
|
for (size_t i = 0; i < arr_len; i++) {
|
|
|
SCDString_free((*arr) + i);
|
|
|
}
|