diff --git a/thirdparty/sdd.c b/thirdparty/sdd.c index f69b2af..a36ae2c 100644 --- a/thirdparty/sdd.c +++ b/thirdparty/sdd.c @@ -51,7 +51,7 @@ typedef struct sdd_header { #define SDD_HDR(s) ((sdd_header *)s - 1) #if defined(__GNUC__) || defined(__clang__) -#define SDD_NOINLINE __attribute__((noinline)) +#define SDD_NOINLINE __attribute__((noinline, noclone)) #elif defined(_MSC_VER) #define SDD_NOINLINE __declspec(noinline) #else @@ -104,16 +104,13 @@ sdd sdd_newlen(void const *init_str, size_t len) { header->len = len; header->cap = len; str = (char *)(header + 1); - if (len) - memcpy(str, init_str, len); + memcpy(str, init_str, len); str[len] = '\0'; return str; } -sdd sdd_new(char const *str) { - size_t len = str ? strlen(str) : 0; - return sdd_newlen(str, len); -} +sdd sdd_new(char const *str) { return sdd_newlen(str, strlen(str)); } + sdd sdd_newvprintf(char const *fmt, va_list ap) { return sdd_impl_catvprintf(NULL, fmt, ap); } diff --git a/thirdparty/sdd.h b/thirdparty/sdd.h index 79b78c4..e94f95c 100644 --- a/thirdparty/sdd.h +++ b/thirdparty/sdd.h @@ -17,9 +17,9 @@ typedef char *sdd; -sdd sdd_new(char const *str) SDD_ALLOCS; +sdd sdd_new(char const *str) SDD_NONNULL() SDD_ALLOCS; // ^- Create new with copy of null-terminated cstring. -sdd sdd_newlen(void const *str, size_t len) SDD_ALLOCS; +sdd sdd_newlen(void const *str, size_t len) SDD_NONNULL() SDD_ALLOCS; // ^- Same, but without calling strlen(). // Resulting new string will be null terminated. sdd sdd_newcap(size_t cap) SDD_ALLOCS; @@ -42,9 +42,9 @@ size_t sdd_cap(sdd const str) SDD_NONNULL(); size_t sdd_avail(sdd const str) SDD_NONNULL(); // ^- cap - len -sdd sdd_cat(sdd str, char const *other) SDD_NONNULL() SDD_RESULT; -sdd sdd_catlen(sdd str, char const *other, size_t len) SDD_RESULT; -sdd sdd_catsdd(sdd str, sdd const other) SDD_RESULT; +sdd sdd_cat(sdd str, char const *restrict other) SDD_NONNULL() SDD_RESULT; +sdd sdd_catlen(sdd str, char const *restrict other, size_t len) SDD_RESULT; +sdd sdd_catsdd(sdd str, sdd restrict const other) SDD_RESULT; sdd sdd_catvprintf(sdd str, char const *fmt, va_list ap) SDD_RESULT; sdd sdd_catprintf(sdd str, char const *fmt, ...) SDD_PRINTF(2, 3) SDD_RESULT; @@ -54,9 +54,9 @@ sdd sdd_makeroomfor(sdd str, size_t add_len) SDD_NONNULL() SDD_RESULT; void sdd_pokelen(sdd str, size_t len) SDD_NONNULL(); // ^- Manually update length field. Doesn't do anything else for you. -bool sdd_equal(sdd const lhs, sdd const rhs) SDD_NONULL(); +bool sdd_equal(sdd const lhs, sdd const rhs) SDD_NONNULL(); -sdd sdd_trim(sdd str, char const *cut_set) SDD_RESULT SDD_NONULL(); +sdd sdd_trim(sdd str, char const *cut_set) SDD_RESULT SDD_NONNULL(); size_t sdd_totalmemused(sdd const str);