ref: 3c1603ee6488f094855150b15c17231b3273d01f
parent: a5bea69b725259e74e806ae8d3b464c23cb073bf
author: cancel <cancel@cancel.fm>
date: Tue Jan 7 20:46:35 EST 2020
Cleanup
--- a/thirdparty/sdd.c
+++ b/thirdparty/sdd.c
@@ -51,7 +51,7 @@
#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 @@
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);
}
--- 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_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 @@
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);