Skip to content

Commit

Permalink
Merge branch 'rs/strbuf-setlen-assert'
Browse files Browse the repository at this point in the history
* rs/strbuf-setlen-assert:
  strbuf: clarify assertion in strbuf_setlen()
  • Loading branch information
Junio C Hamano committed May 1, 2011
2 parents 638e90c + 7141efa commit 5ae6f5c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions strbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

/* See Documentation/technical/api-strbuf.txt */

#include <assert.h>

extern char strbuf_slopbuf[];
struct strbuf {
size_t alloc;
Expand Down Expand Up @@ -33,9 +31,8 @@ static inline size_t strbuf_avail(const struct strbuf *sb) {
extern void strbuf_grow(struct strbuf *, size_t);

static inline void strbuf_setlen(struct strbuf *sb, size_t len) {
if (!sb->alloc)
strbuf_grow(sb, 0);
assert(len < sb->alloc);
if (len > (sb->alloc ? sb->alloc - 1 : 0))
die("BUG: strbuf_setlen() beyond buffer");
sb->len = len;
sb->buf[len] = '\0';
}
Expand Down

0 comments on commit 5ae6f5c

Please sign in to comment.