diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-02-17 13:22:17 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-02-17 13:22:17 -0800 |
| commit | 9f3f38769d49255d3fbf97f35a0dec591de17db3 (patch) | |
| tree | d0b4e0ef5aab675c75932a5cf888c4f32397497f /strbuf.h | |
| parent | cbecc168d4264d93295cd1e0a48dc19f0ed1880c (diff) | |
| parent | 517b60564e2c69cbb79895e04b24a6393273398f (diff) | |
| download | git-9f3f38769d49255d3fbf97f35a0dec591de17db3.tar.xz | |
Merge branch 'rs/strbuf-insertstr'
Code clean-up.
* rs/strbuf-insertstr:
mailinfo: don't insert header prefix for handle_content_type()
strbuf: add and use strbuf_insertstr()
Diffstat (limited to 'strbuf.h')
| -rw-r--r-- | strbuf.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -245,6 +245,18 @@ void strbuf_addchars(struct strbuf *sb, int c, size_t n); void strbuf_insert(struct strbuf *sb, size_t pos, const void *, size_t); /** + * Insert a NUL-terminated string to the given position of the buffer. + * The remaining contents will be shifted, not overwritten. It's an + * inline function to allow the compiler to resolve strlen() calls on + * constants at compile time. + */ +static inline void strbuf_insertstr(struct strbuf *sb, size_t pos, + const char *s) +{ + strbuf_insert(sb, pos, s, strlen(s)); +} + +/** * Insert data to the given position of the buffer giving a printf format * string. The contents will be shifted, not overwritten. */ |
