summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2007-12-09 19:30:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-12-15 05:31:59 (GMT)
commit028c2976389f70e7349bbfeeef0ed0a000d5e447 (patch)
treed5face19a3fdbf6c20345c5d41ab37d66f8b4977 /transport.c
parente8dc37e0e30dbbed532b7471516d1ba5e6e08f27 (diff)
downloadgit-028c2976389f70e7349bbfeeef0ed0a000d5e447.zip
git-028c2976389f70e7349bbfeeef0ed0a000d5e447.tar.gz
git-028c2976389f70e7349bbfeeef0ed0a000d5e447.tar.bz2
Use strbuf in http code
Also, replace whitespaces with tabs in some places Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/transport.c b/transport.c
index 1f840a0..4e151a9 100644
--- a/transport.c
+++ b/transport.c
@@ -428,7 +428,7 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
static struct ref *get_refs_via_curl(struct transport *transport)
{
- struct buffer buffer;
+ struct strbuf buffer = STRBUF_INIT;
char *data, *start, *mid;
char *ref_name;
char *refs_url;
@@ -441,11 +441,6 @@ static struct ref *get_refs_via_curl(struct transport *transport)
struct ref *ref = NULL;
struct ref *last_ref = NULL;
- data = xmalloc(4096);
- buffer.size = 4096;
- buffer.posn = 0;
- buffer.buffer = data;
-
refs_url = xmalloc(strlen(transport->url) + 11);
sprintf(refs_url, "%s/info/refs", transport->url);
@@ -464,27 +459,26 @@ static struct ref *get_refs_via_curl(struct transport *transport)
if (start_active_slot(slot)) {
run_active_slot(slot);
if (results.curl_result != CURLE_OK) {
+ strbuf_release(&buffer);
if (missing_target(&results)) {
- free(buffer.buffer);
return NULL;
} else {
- free(buffer.buffer);
error("%s", curl_errorstr);
return NULL;
}
}
} else {
- free(buffer.buffer);
+ strbuf_release(&buffer);
error("Unable to start request");
return NULL;
}
http_cleanup();
- data = buffer.buffer;
+ data = buffer.buf;
start = NULL;
mid = data;
- while (i < buffer.posn) {
+ while (i < buffer.len) {
if (!start)
start = &data[i];
if (data[i] == '\t')
@@ -507,7 +501,7 @@ static struct ref *get_refs_via_curl(struct transport *transport)
i++;
}
- free(buffer.buffer);
+ strbuf_release(&buffer);
return refs;
}