diff options
| author | Tyge Løvset <[email protected]> | 2022-03-26 16:21:39 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-03-26 16:21:39 +0100 |
| commit | 920a55280a28ce38b98045f797067e285395bb6e (patch) | |
| tree | d3afd64cf8ae1270324c82391bafbd9413e49749 /include/stc/forward.h | |
| parent | f943c8b7a6e46dc002ffc63c9fbcc111f6dca55d (diff) | |
| download | STC-modified-920a55280a28ce38b98045f797067e285395bb6e.tar.gz STC-modified-920a55280a28ce38b98045f797067e285395bb6e.zip | |
Fixed alt/cstr.h (short string optimized), so that it can be used in containers. Had to change some API in csview to make it play with that.
Diffstat (limited to 'include/stc/forward.h')
| -rw-r--r-- | include/stc/forward.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/stc/forward.h b/include/stc/forward.h index bffdf154..ea552204 100644 --- a/include/stc/forward.h +++ b/include/stc/forward.h @@ -42,7 +42,15 @@ #define forward_cqueue(CX, VAL) _c_cdeq_types(CX, VAL)
#define forward_cvec(CX, VAL) _c_cvec_types(CX, VAL)
-typedef struct cstr { char* str; } cstr;
+#ifdef CSTR_IS_SSO
+typedef struct { char* data; size_t size, cap; } _cstr_rep_t;
+typedef union {
+ struct { char data[sizeof(_cstr_rep_t) - 1], cap_len; } sso;
+ struct { char* data; size_t size, ncap; } lon;
+} cstr;
+#else
+ typedef struct cstr { char* str; } cstr;
+#endif
typedef char cstr_value;
typedef struct csview { const char* str; size_t size; } csview;
|
