|
|
|
@ -41,7 +41,7 @@ TYPED_GQUEUE(str, str)
|
|
|
|
#define STR_GS(s) ((str) { (s)->str, (s)->len })
|
|
|
|
#define STR_GS(s) ((str) { (s)->str, (s)->len })
|
|
|
|
#define STR_LEN(s, len) ((str) { (char *) (s), len })
|
|
|
|
#define STR_LEN(s, len) ((str) { (char *) (s), len })
|
|
|
|
#define STR_LEN_ASSERT(s, len) ({ assert(sizeof(s) >= len); (str) { (char *) (s), len }; })
|
|
|
|
#define STR_LEN_ASSERT(s, len) ({ assert(sizeof(s) >= len); (str) { (char *) (s), len }; })
|
|
|
|
#define STR_INIT_DUP(s) ((str) { g_strdup(s), strlen(s) })
|
|
|
|
#define STR_DUP(s) ((str) { g_strdup(s), strlen(s) })
|
|
|
|
#define STR_CONST_BUF(buf) ((str) { (char *) &buf, sizeof(buf) })
|
|
|
|
#define STR_CONST_BUF(buf) ((str) { (char *) &buf, sizeof(buf) })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -86,10 +86,6 @@ INLINE int str_cmp_str0(const str *a, const str *b);
|
|
|
|
__attribute__((nonnull(1)))
|
|
|
|
__attribute__((nonnull(1)))
|
|
|
|
ACCESS(write_only, 1)
|
|
|
|
ACCESS(write_only, 1)
|
|
|
|
ACCESS(read_only, 2)
|
|
|
|
ACCESS(read_only, 2)
|
|
|
|
INLINE str *str_init_dup(str *out, const char *s);
|
|
|
|
|
|
|
|
__attribute__((nonnull(1)))
|
|
|
|
|
|
|
|
ACCESS(write_only, 1)
|
|
|
|
|
|
|
|
ACCESS(read_only, 2)
|
|
|
|
|
|
|
|
INLINE str *str_init_dup_str(str *out, const str *s);
|
|
|
|
INLINE str *str_init_dup_str(str *out, const str *s);
|
|
|
|
INLINE void str_free_dup(str *out);
|
|
|
|
INLINE void str_free_dup(str *out);
|
|
|
|
/* returns new str object with uninitialized buffer large enough to hold `len` characters (+1 for null byte) */
|
|
|
|
/* returns new str object with uninitialized buffer large enough to hold `len` characters (+1 for null byte) */
|
|
|
|
@ -295,11 +291,6 @@ INLINE int str_cmp_str0(const str *a, const str *b) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str_cmp_str(a, b);
|
|
|
|
return str_cmp_str(a, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
INLINE str *str_init_dup(str *out, const char *s) {
|
|
|
|
|
|
|
|
out->s = s ? g_strdup(s) : NULL;
|
|
|
|
|
|
|
|
out->len = s ? strlen(s) : 0;
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
INLINE str *str_init_dup_str(str *out, const str *s) {
|
|
|
|
INLINE str *str_init_dup_str(str *out, const str *s) {
|
|
|
|
if (!s) {
|
|
|
|
if (!s) {
|
|
|
|
*out = STR_NULL;
|
|
|
|
*out = STR_NULL;
|
|
|
|
|