git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Hengeveld <nickh@reactrix.com>
To: git@vger.kernel.org
Subject: [PATCH 5/5] http-push memory/fd cleanup
Date: Fri, 18 Nov 2005 11:03:25 -0800	[thread overview]
Message-ID: <20051118190324.GJ3968@reactrix.com> (raw)

Clean up memory and file descriptor usage

Signed-off-by: Nick Hengeveld <nickh@reactrix.com>


---

 http-push.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

applies-to: 697c3fa609568c3befb803dd8a131814ca1fad6a
898a8d2e69916757f423a8bd487d97f19c06c1e0
diff --git a/http-push.c b/http-push.c
index 2932693..f3c92c9 100644
--- a/http-push.c
+++ b/http-push.c
@@ -165,6 +165,7 @@ static void start_check(struct transfer_
 	} else {
 		request->state = ABORTED;
 		free(request->url);
+		request->url = NULL;
 	}
 }
 
@@ -198,6 +199,7 @@ static void start_mkcol(struct transfer_
 	} else {
 		request->state = ABORTED;
 		free(request->url);
+		request->url = NULL;
 	}
 }
 
@@ -244,8 +246,6 @@ static void start_put(struct transfer_re
 	request->buffer.size = stream.total_out;
 	request->buffer.posn = 0;
 
-	if (request->url != NULL)
-		free(request->url);
 	request->url = xmalloc(strlen(remote->url) + 
 			       strlen(request->lock->token) + 51);
 	strcpy(request->url, remote->url);
@@ -281,6 +281,7 @@ static void start_put(struct transfer_re
 	} else {
 		request->state = ABORTED;
 		free(request->url);
+		request->url = NULL;
 	}
 }
 
@@ -306,6 +307,7 @@ static void start_move(struct transfer_r
 	} else {
 		request->state = ABORTED;
 		free(request->url);
+		request->url = NULL;
 	}
 }
 
@@ -370,6 +372,13 @@ static void finish_request(struct transf
 
 	if (request->headers != NULL)
 		curl_slist_free_all(request->headers);
+
+	/* URL is reused for MOVE after PUT */
+	if (request->state != RUN_PUT) {
+		free(request->url);
+		request->url = NULL;
+	}		
+
 	if (request->state == RUN_HEAD) {
 		if (request->http_code == 404) {
 			request->state = NEED_PUSH;
@@ -435,7 +444,8 @@ static void release_request(struct trans
 			entry->next = entry->next->next;
 	}
 
-	free(request->url);
+	if (request->url != NULL)
+		free(request->url);
 	free(request);
 }
 
@@ -575,6 +585,7 @@ static int fetch_index(unsigned char *sh
 		}
 	} else {
 		free(url);
+		fclose(indexfile);
 		return error("Unable to start request");
 	}
 
---
0.99.9.GIT

                 reply	other threads:[~2005-11-18 19:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051118190324.GJ3968@reactrix.com \
    --to=nickh@reactrix.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).