diff options
| author | Tyge Løvset <[email protected]> | 2020-03-23 21:22:00 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-03-23 21:22:00 +0100 |
| commit | 0f8e35b1eaaf576a8d331db081fe7fe1358dd392 (patch) | |
| tree | 017448741314fe73390b4b706b319e493111cedf /c_lib/cstring.h | |
| parent | adcc369478f5e9fea6bd00f119257eea3f8d4fb1 (diff) | |
| download | STC-modified-0f8e35b1eaaf576a8d331db081fe7fe1358dd392.tar.gz STC-modified-0f8e35b1eaaf576a8d331db081fe7fe1358dd392.zip | |
Add files via upload
Diffstat (limited to 'c_lib/cstring.h')
| -rw-r--r-- | c_lib/cstring.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/c_lib/cstring.h b/c_lib/cstring.h index e40721fc..af5e2eaf 100644 --- a/c_lib/cstring.h +++ b/c_lib/cstring.h @@ -233,10 +233,20 @@ static inline char* cstring_splitNext(const char* delimiters) { return strtok(NULL, delimiters);
}
+#pragma warning(disable:4172)
+static inline CString cstring_tmp1k(const char* str) {
+ enum {N = 1000};
+ size_t len = strlen(str); if (len > N) len = N;
+ size_t buf[3 + N / sizeof(size_t)] = {strlen(str), 0, 0};
+ strncpy((char *) (buf + 2), str, N);
+ CString tmp = {(char *) (buf + 2)};
+ return tmp;
+}
+#pragma warning(default:4172)
// CVector / CMap API functions:
-#define cstring_getRaw(x) ((x).str)
+#define cstring_getRaw(x) ((x)->str)
static inline uint32_t cstring_hashRaw(const char** str, size_t sz_ignored) { return c_defaultHash(*str, strlen(*str)); }
|
