This is useful for determining how big of a buffer to allocate.
---
 lib/util/stringutils.c | 5 ++++-
 lib/util/stringutils.h | 7 ++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/util/stringutils.c b/lib/util/stringutils.c
index 6e15226..911eacf 100644
--- a/lib/util/stringutils.c
+++ b/lib/util/stringutils.c
@@ -307,7 +307,10 @@ char *scrub_for_print(
     size_t used = 0;
     size_t len_out = 0;
 
-    dst[0] = '\0';
+    if (dst_sz)
+    {
+        dst[0] = '\0';
+    }
 
     for (i = 0; src[i]; i++)
     {
diff --git a/lib/util/stringutils.h b/lib/util/stringutils.h
index 6db8663..f8831b5 100644
--- a/lib/util/stringutils.h
+++ b/lib/util/stringutils.h
@@ -145,12 +145,13 @@ int expand_by_doubling(
  * @note dst will be null terminated, at or before index dst_sz-1.
  *
  * @param[out] dst
- *     Location of the buffer to hold the output string.  This must
- *     not be NULL.
+ *     Location of the buffer to hold the output string.  This may be
+ *     NULL, but only if @p dst_sz is 0.
  * @param[in] src
  *     The input string to escape.  This must not be NULL.
  * @param[in] dst_sz
- *     Size of the buffer at @p dst.  This must not be 0.
+ *     Size of the buffer at @p dst.  This may be 0, in which case @p
+ *     dst is ignored.
  * @param[out] dst_len_out
  *     On successful return, the value at this location will be set to
  *     the length of the escaped string (excluding the nul terminator)
-- 
2.4.3


------------------------------------------------------------------------------
_______________________________________________
rpstir-devel mailing list
rpstir-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpstir-devel

Reply via email to