diff --git a/misc.h b/misc.h index 40191724..4e0d8b2d 100644 --- a/misc.h +++ b/misc.h @@ -107,6 +107,12 @@ int string_length_for_printf(size_t); /* Derive two printf arguments from a ptrlen, suitable for "%.*s" */ #define PTRLEN_PRINTF(pl) \ string_length_for_printf((pl).len), (const char *)(pl).ptr +/* Make a ptrlen out of a compile-time string literal. We try to + * enforce that it _is_ a string literal by token-pasting "" on to it, + * which should provoke a compile error if it's any other kind of + * string. */ +#define PTRLEN_LITERAL(stringlit) \ + TYPECHECK("" stringlit "", make_ptrlen(stringlit, sizeof(stringlit)-1)) /* Wipe sensitive data out of memory that's about to be freed. Simpler * than memset because we don't need the fill char parameter; also