aboutsummaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-24 14:28:41 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-24 14:28:41 -0700
commit50f03c6676ed5ea040dd53272882d3aac2ee1b48 (patch)
tree8bf9680918762ffa077832674da9cca98c8c1888 /http.c
parentcda4ba30b1d6257524b9412ed4d7c44645fe0369 (diff)
parent88ce3ef636b1385e861ec0e9e2155248b999b032 (diff)
downloadgit-50f03c6676ed5ea040dd53272882d3aac2ee1b48.tar.gz
git-50f03c6676ed5ea040dd53272882d3aac2ee1b48.tar.xz
Merge branch 'ab/free-and-null'
A common pattern to free a piece of memory and assign NULL to the pointer that used to point at it has been replaced with a new FREE_AND_NULL() macro. * ab/free-and-null: *.[ch] refactoring: make use of the FREE_AND_NULL() macro coccinelle: make use of the "expression" FREE_AND_NULL() rule coccinelle: add a rule to make "expression" code use FREE_AND_NULL() coccinelle: make use of the "type" FREE_AND_NULL() rule coccinelle: add a rule to make "type" code use FREE_AND_NULL() git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL
Diffstat (limited to 'http.c')
-rw-r--r--http.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/http.c b/http.c
index 013bb0cc6..c6c010f88 100644
--- a/http.c
+++ b/http.c
@@ -1027,8 +1027,7 @@ void http_cleanup(void)
if (proxy_auth.password) {
memset(proxy_auth.password, 0, strlen(proxy_auth.password));
- free(proxy_auth.password);
- proxy_auth.password = NULL;
+ FREE_AND_NULL(proxy_auth.password);
}
free((void *)curl_proxyuserpwd);
@@ -1039,13 +1038,11 @@ void http_cleanup(void)
if (cert_auth.password != NULL) {
memset(cert_auth.password, 0, strlen(cert_auth.password));
- free(cert_auth.password);
- cert_auth.password = NULL;
+ FREE_AND_NULL(cert_auth.password);
}
ssl_cert_password_required = 0;
- free(cached_accept_language);
- cached_accept_language = NULL;
+ FREE_AND_NULL(cached_accept_language);
}
struct active_request_slot *get_active_slot(void)
@@ -1897,8 +1894,7 @@ static char *fetch_pack_index(unsigned char *sha1, const char *base_url)
if (http_get_file(url, tmp, NULL) != HTTP_OK) {
error("Unable to get pack index %s", url);
- free(tmp);
- tmp = NULL;
+ FREE_AND_NULL(tmp);
}
free(url);
@@ -2329,8 +2325,7 @@ void release_http_object_request(struct http_object_request *freq)
freq->localfile = -1;
}
if (freq->url != NULL) {
- free(freq->url);
- freq->url = NULL;
+ FREE_AND_NULL(freq->url);
}
if (freq->slot != NULL) {
freq->slot->callback_func = NULL;