diff options
| author | spl3g <spleefer6@yandex.ru> | 2025-03-21 13:37:06 +0300 |
|---|---|---|
| committer | spl3g <spleefer6@yandex.ru> | 2025-03-21 13:37:06 +0300 |
| commit | 11d0fe6912ca72f2ae8ab057b7e9eeb9a4b7c15e (patch) | |
| tree | 7ba5e59fc706663011bae9013933a26670a4b3fc | |
| parent | a882370db3fb6deea312c747f7c16d7ce9434caf (diff) | |
Replace cs_to_cstr with 2 fmt macros
| -rw-r--r-- | lib/const_strings.c | 5 | ||||
| -rw-r--r-- | lib/const_strings.h | 8 |
2 files changed, 3 insertions, 10 deletions
diff --git a/lib/const_strings.c b/lib/const_strings.c index 837b138..2d743b1 100644 --- a/lib/const_strings.c +++ b/lib/const_strings.c @@ -12,11 +12,6 @@ const_string cs_from_cstr(const char* cstr) { return cs_from_parts(cstr, strlen(cstr)); } -char* cs_to_cstr(const_string str) { - str.data[str.len] = '\0'; - return str.data; -} - const_string cs_slice(const_string src, int from, int to) { if (from > src.len) { return src; diff --git a/lib/const_strings.h b/lib/const_strings.h index aaafd81..cb92442 100644 --- a/lib/const_strings.h +++ b/lib/const_strings.h @@ -10,7 +10,6 @@ typedef struct { int len; } const_string; - const_string cs_from_parts(const char* data, int len); const_string cs_from_cstr(const char* cstr); const_string cs_slice(const_string src, int from, int to); @@ -23,8 +22,7 @@ void cs_print(char *format, const_string str); #define CS(cstr) cs_from_parts(cstr, sizeof(cstr) - 1) #define CS_STATIC(cstr) {.data = cstr, .len = sizeof(cstr) - 1} -#endif // STRINGS_H_ - +#define CS_FMT "%.*s" +#define CS_ARG(cs) (int) (cs).len, (cs).data -#ifdef CONST_STRINGS_IMPLEMENTATION -#endif // STRINGS_IMPLEMENTATION +#endif // STRINGS_H_ |
