From f30d75ae5dba339bfc95229894b22fd73e3fdc14 Mon Sep 17 00:00:00 2001 From: rajdakin Date: Sat, 7 Sep 2024 20:53:51 +0200 Subject: [WRAPPERHELPER] General improvements (#1804) * [WRAPPERHELPER] Automatic headers detection, various bug fixes, added some cast support * [WRAPPERHELPER] Keep comments untouched --- wrapperhelper/src/cstring.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'wrapperhelper/src/cstring.h') diff --git a/wrapperhelper/src/cstring.h b/wrapperhelper/src/cstring.h index 12c7df4c..15ecd026 100644 --- a/wrapperhelper/src/cstring.h +++ b/wrapperhelper/src/cstring.h @@ -15,12 +15,14 @@ * string_new_cap ------ Creates a new string with a given capacity. Takes the capacity. * string_new_cstr ----- Creates a new string from a given C string. Takes the string. * string_reserve ------ Ensures a string has at least a given capacity. Takes the string and the capacity. + * string_trim --------- Ensures a string has a capacity equal to its length. Takes the string. May reduce the string capacity. * string_del ---------- Frees a string. Takes the string. * string_steal -------- Frees a string, keeping the content alive. Takes the string. The content (also returned) needs to be freed separately. * string_add_char ----- Add a character at the end. Takes the string and the new character. May increase the string capacity. * string_add_string --- Add a string at the end in-place. Takes both strings. May increase the string capacity. * string_add_cstr ----- Add a C string at the end in-place. Takes both strings. May increase the string capacity. * string_pop ---------- Pops the last character. Takes the string. May reduce the string capacity. + * string_clear -------- Clears the string. Takes the string. May reduce the string capacity. * string_dup ---------- Duplicate a string. Takes the string. Does not free the old string. * string_concat ------- Concatenate two strings. Takes both strings. Does not free any string. * string_len ---------- String length. Takes the string. @@ -62,12 +64,14 @@ string_t *string_new(void); string_t *string_new_cap(size_t cap); string_t *string_new_cstr(const char *s); int string_reserve(string_t *s, size_t cap); +int string_trim(string_t *s); void string_del(string_t *s); char *string_steal(string_t *s); int string_add_char(string_t *s, char elem); int string_add_string(string_t *s1, string_t *s2); int string_add_cstr(string_t *s1, const char *s2); void string_pop(string_t *s); +void string_clear(string_t *s); string_t *string_dup(string_t const *s); string_t *string_concat(string_t const *l, string_t const *r); #define string_len(s) ((s)->ssize) -- cgit 1.4.1