aboutsummaryrefslogtreecommitdiff
path: root/builtin-fetch--tool.c
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-09-10 12:35:07 +0200
committerJunio C Hamano <gitster@pobox.com>2007-09-10 12:50:28 -0700
commitb655d46bb2d8aa12f3203f93c323b41df161fd26 (patch)
treee1a921cffc8a7a63d901b31e59d7d1d38a4f9aed /builtin-fetch--tool.c
parent674d1727305211f7ade4ade70440220f74f55162 (diff)
downloadgit-b655d46bb2d8aa12f3203f93c323b41df161fd26.tar.gz
git-b655d46bb2d8aa12f3203f93c323b41df161fd26.tar.xz
Use strbuf_read in builtin-fetch-tool.c.
xrealloc.use --; Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-fetch--tool.c')
-rw-r--r--builtin-fetch--tool.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 24c7e6f7d..90bdc32d1 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -2,27 +2,16 @@
#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)