summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
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 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;
}