|
|
|
@ -61,7 +61,7 @@ INLINE str *str_init_len(str *out, char *s, size_t len);
|
|
|
|
INLINE str *str_init_len_assert_len(str *out, char *s, size_t buflen, size_t len);
|
|
|
|
INLINE str *str_init_len_assert_len(str *out, char *s, size_t buflen, size_t len);
|
|
|
|
#define str_init_len_assert(out, s, len) str_init_len_assert_len(out, s, sizeof(s), len)
|
|
|
|
#define str_init_len_assert(out, s, len) str_init_len_assert_len(out, s, sizeof(s), len)
|
|
|
|
/* inits a str object from a regular string and duplicates the contents. returns out */
|
|
|
|
/* inits a str object from a regular string and duplicates the contents. returns out */
|
|
|
|
INLINE str *str_init_dup(str *out, char *s);
|
|
|
|
INLINE str *str_init_dup(str *out, const char *s);
|
|
|
|
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) */
|
|
|
|
@ -232,7 +232,7 @@ INLINE str *str_init_len_assert_len(str *out, char *s, size_t buflen, size_t len
|
|
|
|
assert(buflen >= len);
|
|
|
|
assert(buflen >= len);
|
|
|
|
return str_init_len(out, s, len);
|
|
|
|
return str_init_len(out, s, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
INLINE str *str_init_dup(str *out, char *s) {
|
|
|
|
INLINE str *str_init_dup(str *out, const char *s) {
|
|
|
|
out->s = s ? strdup(s) : NULL;
|
|
|
|
out->s = s ? strdup(s) : NULL;
|
|
|
|
out->len = s ? strlen(s) : 0;
|
|
|
|
out->len = s ? strlen(s) : 0;
|
|
|
|
return out;
|
|
|
|
return out;
|
|
|
|
|