diff options
author | Mike Hommey <mh@glandium.org> | 2007-12-09 20:30:59 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-14 21:31:59 -0800 |
commit | 028c2976389f70e7349bbfeeef0ed0a000d5e447 (patch) | |
tree | d5face19a3fdbf6c20345c5d41ab37d66f8b4977 /transport.c | |
parent | e8dc37e0e30dbbed532b7471516d1ba5e6e08f27 (diff) | |
download | git-028c2976389f70e7349bbfeeef0ed0a000d5e447.tar.gz |
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.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/transport.c b/transport.c index 1f840a0498..4e151a9e87 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; } |