diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-02-03 19:43:53 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-02-03 19:43:53 +0300 |
commit | c299128eaefc813d1a6acdca8a9c724145686177 (patch) | |
tree | 3c0131fa32fe6f29acc88c5b0d934eb76fadd2a3 /src/utils.c | |
parent | 26405332102756912ab2c175874555d6eb8c332f (diff) | |
download | magi-c299128eaefc813d1a6acdca8a9c724145686177.tar magi-c299128eaefc813d1a6acdca8a9c724145686177.tar.xz magi-c299128eaefc813d1a6acdca8a9c724145686177.zip |
[magi] Readme added + fixes.
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/utils.c b/src/utils.c deleted file mode 100644 index 931d1e4..0000000 --- a/src/utils.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "utils.h" - -#include <ctype.h> -#include <stdlib.h> -#include <string.h> - - -void magi_str_lowercase(char * str) -{ - if (str) { - while (*str) { - *str = tolower(*str); - ++str; - } - } -} - -char * magi_str_create_copy(const char * begin, const char * end) -{ - char * res; - res = malloc(end - begin + 1); - if (res) { - memcpy(res, begin, end - begin); - res[end - begin] = 0; - } - return res; -} - -char * magi_str_create(int len) -{ - char * str = malloc(len + 1); - if (str) { - str[len] = 0; - } - return str; -} - -int magi_str_add(char ** dest, int * len, int * size, char c) -{ - if (*len + 1 == *size) { - *size *= 2; - *dest = realloc(*dest, *size); - } - if (*dest) { - (*dest)[*len] = c; - ++*len; - (*dest)[*len] = 0; - } - return !!*dest; -} |