projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gitweb.cgi history not shown
[git.git]
/
strbuf.c
diff --git
a/strbuf.c
b/strbuf.c
index
dac945c
..
9d9d8be
100644
(file)
--- a/
strbuf.c
+++ b/
strbuf.c
@@
-1,9
+1,10
@@
#include <stdio.h>
#include <stdlib.h>
#include "strbuf.h"
#include <stdio.h>
#include <stdlib.h>
#include "strbuf.h"
+#include "cache.h"
void strbuf_init(struct strbuf *sb) {
void strbuf_init(struct strbuf *sb) {
- sb->buf =
0
;
+ sb->buf =
NULL
;
sb->eof = sb->alloc = sb->len = 0;
}
sb->eof = sb->alloc = sb->len = 0;
}
@@
-15,7
+16,7
@@
static void strbuf_begin(struct strbuf *sb) {
static void inline strbuf_add(struct strbuf *sb, int ch) {
if (sb->alloc <= sb->len) {
sb->alloc = sb->alloc * 3 / 2 + 16;
static void inline strbuf_add(struct strbuf *sb, int ch) {
if (sb->alloc <= sb->len) {
sb->alloc = sb->alloc * 3 / 2 + 16;
- sb->buf = realloc(sb->buf, sb->alloc);
+ sb->buf =
x
realloc(sb->buf, sb->alloc);
}
sb->buf[sb->len++] = ch;
}
}
sb->buf[sb->len++] = ch;
}
@@
-36,7
+37,7
@@
void read_line(struct strbuf *sb, FILE *fp, int term) {
break;
strbuf_add(sb, ch);
}
break;
strbuf_add(sb, ch);
}
- if (sb->len == 0)
+ if (
ch == EOF &&
sb->len == 0)
sb->eof = 1;
strbuf_end(sb);
}
sb->eof = 1;
strbuf_end(sb);
}