strbuf_read_file enhancement, and use it.
* make strbuf_read_file take a size hint (works like strbuf_read) * use it in a couple of places. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b315c5c081
commit
387e7e19d7
4
strbuf.c
4
strbuf.c
@ -186,14 +186,14 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strbuf_read_file(struct strbuf *sb, const char *path)
|
||||
int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
|
||||
{
|
||||
int fd, len;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
len = strbuf_read(sb, fd, 0);
|
||||
len = strbuf_read(sb, fd, hint);
|
||||
close(fd);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user