summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 674d172)
raw | patch | inline | side by side (parent: 674d172)
author | Pierre Habouzit <madcoder@debian.org> | |
Mon, 10 Sep 2007 10:35:07 +0000 (12:35 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 10 Sep 2007 19:50:28 +0000 (12:50 -0700) |
xrealloc.use --;
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fetch--tool.c | patch | blob | history |
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 24c7e6f7dbcee4d02daad7182bb7587c4c9c3418..90bdc32d13babeec7693cc27b48d5b1faf4b8dca 100644 (file)
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
#include "cache.h"
#include "refs.h"
#include "commit.h"
-
-#define CHUNK_SIZE 1024
+#include "strbuf.h"
static char *get_stdin(void)
{
- size_t offset = 0;
- char *data = xmalloc(CHUNK_SIZE);
-
- while (1) {
- ssize_t cnt = xread(0, data + offset, CHUNK_SIZE);
- if (cnt < 0)
- die("error reading standard input: %s",
- strerror(errno));
- if (cnt == 0) {
- data[offset] = 0;
- break;
- }
- offset += cnt;
- data = xrealloc(data, offset + CHUNK_SIZE);
+ struct strbuf buf;
+ strbuf_init(&buf, 0);
+ if (strbuf_read(&buf, 0, 1024) < 0) {
+ die("error reading standard input: %s", strerror(errno));
}
- return data;
+ return strbuf_detach(&buf);
}
static void show_new(enum object_type type, unsigned char *sha1_new)