diff options
author | Pierre Habouzit <madcoder@debian.org> | 2007-09-15 15:56:50 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-16 17:30:03 -0700 |
commit | 917c9a713397b16671ed5b1f1c159515bcfa389e (patch) | |
tree | 666fde07656debe768ad4f388e5a0e87759d3459 /strbuf.h | |
parent | 760da9607ee08e9dd495dee993262bb857694ac9 (diff) | |
download | git-917c9a713397b16671ed5b1f1c159515bcfa389e.tar.gz |
New strbuf APIs: splice and attach.
* strbuf_splice replace a portion of the buffer with another.
* strbuf_attach replace a strbuf buffer with the given one, that should be
malloc'ed. Then it enforces strbuf's invariants. If alloc > len, then this
function has negligible cost, else it will perform a realloc, possibly
with a cost.
Also some style issues are fixed now.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
-rw-r--r-- | strbuf.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -55,6 +55,7 @@ extern void strbuf_init(struct strbuf *, size_t); extern void strbuf_release(struct strbuf *); extern void strbuf_reset(struct strbuf *); extern char *strbuf_detach(struct strbuf *); +extern void strbuf_attach(struct strbuf *, void *, size_t, size_t); /*----- strbuf size related -----*/ static inline size_t strbuf_avail(struct strbuf *sb) { @@ -81,6 +82,10 @@ static inline void strbuf_addch(struct strbuf *sb, int c) { /* inserts after pos, or appends if pos >= sb->len */ extern void strbuf_insert(struct strbuf *, size_t pos, const void *, size_t); +/* splice pos..pos+len with given data */ +extern void strbuf_splice(struct strbuf *, size_t pos, size_t len, + const void *, size_t); + extern void strbuf_add(struct strbuf *, const void *, size_t); static inline void strbuf_addstr(struct strbuf *sb, const char *s) { strbuf_add(sb, s, strlen(s)); |