MINOR: standard: make memprintf() support a NULL destination
Doing so removes many checks that were systematically made because
the callees don't know if the caller passed a valid pointer.
diff --git a/src/standard.c b/src/standard.c
index 31f4ddd..49810fc 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -1788,7 +1788,8 @@
* This means that <err> must be initialized to NULL before first invocation.
* The return value also holds the allocated string, which eases error checking
* and immediate consumption. If the output pointer is not used, NULL must be
- * passed instead and it will be ignored.
+ * passed instead and it will be ignored. The returned message will then also
+ * be NULL so that the caller does not have to bother with freeing anything.
*
* It is also convenient to use it without any free except the last one :
* err = NULL;
@@ -1804,6 +1805,9 @@
int allocated = 0;
int needed = 0;
+ if (!out)
+ return NULL;
+
do {
/* vsnprintf() will return the required length even when the
* target buffer is NULL. We do this in a loop just in case