cstring

Lightweight string library for C
git clone git://git.christosmarg.xyz/cstring.git
Log | Files | Refs | README | LICENSE

commit 3627920b7d721f4a228c8e519af04607bacb7564
parent fd01211bf8b299da3f4828abd701c2261f2a93b1
Author: Christos Margiolis <christos@margiolis.net>
Date:   Thu, 10 Sep 2020 08:42:51 +0300

cstring_init -> cstring_create

Diffstat:
MREADME.md | 8++++----
Mcstring.c | 2+-
Mcstring.h | 2+-
Mtest.c | 4++--
4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md @@ -7,15 +7,15 @@ A simple and lightweight string library for C. Simply include the source files in your projects and compile them along with your other files. -When using this library, you must to **always** call the `cstring_init` and `cstring_delete` +When using this library, you must to **always** call the `cstring_create` and `cstring_delete` functions whenever you want to make a new instance of `cstring` and stop using it respectively, in order not to cause any memory leaks, as there's no *constructor* and *destructor* to do it for you. -The recommended way of initializing an empty string is by doing `cstring foo = cstring_init("")`. +The recommended way of initializing an empty string is by doing `cstring foo = cstring_create("")`. ## Functions -* `cstring_init`: Initiliazes string +* `cstring_create`: Initiliazes string * `cstring_delete`: Deallocates string * `cstring_assign`: Assigns a new string to the current string * `cstring_append`: Appends a string to the current string @@ -49,7 +49,7 @@ See `test.c` for more. int main(int argc, char **argv) { - cstring s = cstring_init("Foo"); + cstring s = cstring_create("Foo"); cstring_append(&s, "Bar."); printf("%s\n", s.str); cstring_delete(&s); diff --git a/cstring.c b/cstring.c @@ -1,7 +1,7 @@ #include "cstring.h" cstring -cstring_init(const char *s) +cstring_create(const char *s) { cstring cs; cs.str = cstring_copy(s); diff --git a/cstring.h b/cstring.h @@ -11,7 +11,7 @@ typedef struct cstring { size_t capacity; } cstring; -extern cstring cstring_init(const char *); +extern cstring cstring_create(const char *); extern void cstring_delete(cstring *); extern void cstring_assign(cstring *, const char *); extern void cstring_append(cstring *, const char *); diff --git a/test.c b/test.c @@ -3,8 +3,8 @@ int main(int argc, char **argv) { - cstring s = cstring_init("Hello world"); - printf("cstring_init: %s (Len: %ld, Capacity: %ld)\n", s.str, s.len, s.capacity); + cstring s = cstring_create("Hello world"); + printf("cstring_create: %s (Len: %ld, Capacity: %ld)\n", s.str, s.len, s.capacity); cstring_append(&s, "Append"); printf("cstring_append: %s (Len: %ld, Capacity: %ld)\n", s.str, s.len, s.capacity);