]> git.ipfire.org Git - thirdparty/git.git/blobdiff - strbuf.h
strbuf_setlen: don't write to strbuf_slopbuf
[thirdparty/git.git] / strbuf.h
index 3646a6291b5026fc6d9e211a0313d76e4d2e100d..1a77fe146a9c0a83bda4461b084148a5a89b63e2 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -147,7 +147,10 @@ static inline void strbuf_setlen(struct strbuf *sb, size_t len)
        if (len > (sb->alloc ? sb->alloc - 1 : 0))
                die("BUG: strbuf_setlen() beyond buffer");
        sb->len = len;
-       sb->buf[len] = '\0';
+       if (sb->buf != strbuf_slopbuf)
+               sb->buf[len] = '\0';
+       else
+               assert(!strbuf_slopbuf[0]);
 }
 
 /**
@@ -334,14 +337,15 @@ extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
 
 /**
  * Add the time specified by `tm`, as formatted by `strftime`.
- * `tz_name` is used to expand %Z internally unless it's NULL.
  * `tz_offset` is in decimal hhmm format, e.g. -600 means six hours west
  * of Greenwich, and it's used to expand %z internally.  However, tokens
  * with modifiers (e.g. %Ez) are passed to `strftime`.
+ * `suppress_tz_name`, when set, expands %Z internally to the empty
+ * string rather than passing it to `strftime`.
  */
 extern void strbuf_addftime(struct strbuf *sb, const char *fmt,
                            const struct tm *tm, int tz_offset,
-                           const char *tz_name);
+                           int suppress_tz_name);
 
 /**
  * Read a given size of data from a FILE* pointer to the buffer.