summaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-07-10 03:03:42 -0400
committerJunio C Hamano <gitster@pobox.com>2017-07-14 08:32:44 -0700
commitcbc0f81d96f05d8c88dd29a69d7571baa204f933 (patch)
tree86eb32c655a2e396a82585c51f252308cbb2a21b /strbuf.h
parentf3da2b79be9565779e4f76dc5812c68e156afdf0 (diff)
downloadgit-cbc0f81d96f05d8c88dd29a69d7571baa204f933.tar.gz
strbuf: use designated initializers in STRBUF_INIT
There are certain C99 features that might be nice to use in our code base, but we've hesitated to do so in order to avoid breaking compatibility with older compilers. But we don't actually know if people are even using pre-C99 compilers these days. One way to figure that out is to introduce a very small use of a feature, and see if anybody complains. The strbuf code is a good place to do this for a few reasons: - it always gets compiled, no matter which Makefile knobs have been tweaked. - it's very stable; this definition hasn't changed in a long time and is not likely to (so if we have to revert, it's unlikely to cause headaches) If this patch can survive a few releases without complaint, then we can feel more confident that designated initializers are widely supported by our user base. It also is an indication that other C99 features may be supported, but not a guarantee (e.g., gcc had designated initializers before C99 existed). And if we do get complaints, then we'll have gained some data and we can easily revert this patch. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/strbuf.h b/strbuf.h
index 2075384e0b..e705b94db5 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -68,7 +68,7 @@ struct strbuf {
};
extern char strbuf_slopbuf[];
-#define STRBUF_INIT { 0, 0, strbuf_slopbuf }
+#define STRBUF_INIT { .alloc = 0, .len = 0, .buf = strbuf_slopbuf }
/**
* Life Cycle Functions