git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5/5] http-push memory/fd cleanup
@ 2005-11-18 19:03 Nick Hengeveld
  0 siblings, 0 replies; only message in thread
From: Nick Hengeveld @ 2005-11-18 19:03 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2005-11-18 19:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-18 19:03 [PATCH 5/5] http-push memory/fd cleanup Nick Hengeveld

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).