free(NULL) is perfectly valid.
Jonas noticed some places say "if (X) free(X)" which is totally unnecessary. Signed-off-by: Junio C Hamano <junkio@cox.net>maint
parent
b3c952f838
commit
4cac42b132
|
@ -1131,8 +1131,7 @@ static struct fragment *parse_binary_hunk(char **buf_p,
|
||||||
return frag;
|
return frag;
|
||||||
|
|
||||||
corrupt:
|
corrupt:
|
||||||
if (data)
|
free(data);
|
||||||
free(data);
|
|
||||||
*status_p = -1;
|
*status_p = -1;
|
||||||
error("corrupt binary patch at line %d: %.*s",
|
error("corrupt binary patch at line %d: %.*s",
|
||||||
linenr-1, llen-1, buffer);
|
linenr-1, llen-1, buffer);
|
||||||
|
@ -1329,8 +1328,7 @@ static void show_stats(struct patch *patch)
|
||||||
printf(" %s%-*s |%5d %.*s%.*s\n", prefix,
|
printf(" %s%-*s |%5d %.*s%.*s\n", prefix,
|
||||||
len, name, patch->lines_added + patch->lines_deleted,
|
len, name, patch->lines_added + patch->lines_deleted,
|
||||||
add, pluses, del, minuses);
|
add, pluses, del, minuses);
|
||||||
if (qname)
|
free(qname);
|
||||||
free(qname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_old_data(struct stat *st, const char *path, void *buf, unsigned long size)
|
static int read_old_data(struct stat *st, const char *path, void *buf, unsigned long size)
|
||||||
|
|
|
@ -55,8 +55,7 @@ static void free_list(struct list *list)
|
||||||
|
|
||||||
for (i = 0; i < list->nr; i++) {
|
for (i = 0; i < list->nr; i++) {
|
||||||
free(list->list[i]);
|
free(list->list[i]);
|
||||||
if (list->payload[i])
|
free(list->payload[i]);
|
||||||
free(list->payload[i]);
|
|
||||||
}
|
}
|
||||||
free(list->list);
|
free(list->list);
|
||||||
free(list->payload);
|
free(list->payload);
|
||||||
|
|
|
@ -122,10 +122,8 @@ static int get_value(const char* key_, const char* regex_)
|
||||||
ret = (seen == 1) ? 0 : 1;
|
ret = (seen == 1) ? 0 : 1;
|
||||||
|
|
||||||
free_strings:
|
free_strings:
|
||||||
if (repo_config)
|
free(repo_config);
|
||||||
free(repo_config);
|
free(global);
|
||||||
if (global)
|
|
||||||
free(global);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,10 +93,8 @@ static void show_commit(struct commit *commit)
|
||||||
free_commit_list(commit->parents);
|
free_commit_list(commit->parents);
|
||||||
commit->parents = NULL;
|
commit->parents = NULL;
|
||||||
}
|
}
|
||||||
if (commit->buffer) {
|
free(commit->buffer);
|
||||||
free(commit->buffer);
|
commit->buffer = NULL;
|
||||||
commit->buffer = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_blob(struct blob *blob,
|
static void process_blob(struct blob *blob,
|
||||||
|
|
6
config.c
6
config.c
|
@ -361,8 +361,7 @@ int git_config(config_fn_t fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += git_config_from_file(fn, filename);
|
ret += git_config_from_file(fn, filename);
|
||||||
if (repo_config)
|
free(repo_config);
|
||||||
free(repo_config);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,8 +733,7 @@ int git_config_set_multivar(const char* key, const char* value,
|
||||||
out_free:
|
out_free:
|
||||||
if (0 <= fd)
|
if (0 <= fd)
|
||||||
close(fd);
|
close(fd);
|
||||||
if (config_filename)
|
free(config_filename);
|
||||||
free(config_filename);
|
|
||||||
if (lock_file) {
|
if (lock_file) {
|
||||||
unlink(lock_file);
|
unlink(lock_file);
|
||||||
free(lock_file);
|
free(lock_file);
|
||||||
|
|
3
fetch.c
3
fetch.c
|
@ -302,8 +302,7 @@ int pull(int targets, char **target, const char **write_ref,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto unlock_and_fail;
|
goto unlock_and_fail;
|
||||||
}
|
}
|
||||||
if (msg)
|
free(msg);
|
||||||
free(msg);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
13
http-fetch.c
13
http-fetch.c
|
@ -696,10 +696,8 @@ xml_start_tag(void *userData, const char *name, const char **atts)
|
||||||
strcat(ctx->name, ".");
|
strcat(ctx->name, ".");
|
||||||
strcat(ctx->name, c);
|
strcat(ctx->name, c);
|
||||||
|
|
||||||
if (ctx->cdata) {
|
free(ctx->cdata);
|
||||||
free(ctx->cdata);
|
ctx->cdata = NULL;
|
||||||
ctx->cdata = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->userFunc(ctx, 0);
|
ctx->userFunc(ctx, 0);
|
||||||
}
|
}
|
||||||
|
@ -726,8 +724,7 @@ static void
|
||||||
xml_cdata(void *userData, const XML_Char *s, int len)
|
xml_cdata(void *userData, const XML_Char *s, int len)
|
||||||
{
|
{
|
||||||
struct xml_ctx *ctx = (struct xml_ctx *)userData;
|
struct xml_ctx *ctx = (struct xml_ctx *)userData;
|
||||||
if (ctx->cdata)
|
free(ctx->cdata);
|
||||||
free(ctx->cdata);
|
|
||||||
ctx->cdata = xmalloc(len + 1);
|
ctx->cdata = xmalloc(len + 1);
|
||||||
strlcpy(ctx->cdata, s, len + 1);
|
strlcpy(ctx->cdata, s, len + 1);
|
||||||
}
|
}
|
||||||
|
@ -765,9 +762,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
|
||||||
ls->dentry_flags |= IS_DIR;
|
ls->dentry_flags |= IS_DIR;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
|
} else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
|
||||||
if (ls->dentry_name) {
|
free(ls->dentry_name);
|
||||||
free(ls->dentry_name);
|
|
||||||
}
|
|
||||||
ls->dentry_name = NULL;
|
ls->dentry_name = NULL;
|
||||||
ls->dentry_flags = 0;
|
ls->dentry_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
13
http-push.c
13
http-push.c
|
@ -1238,10 +1238,8 @@ xml_start_tag(void *userData, const char *name, const char **atts)
|
||||||
strcat(ctx->name, ".");
|
strcat(ctx->name, ".");
|
||||||
strcat(ctx->name, c);
|
strcat(ctx->name, c);
|
||||||
|
|
||||||
if (ctx->cdata) {
|
free(ctx->cdata);
|
||||||
free(ctx->cdata);
|
ctx->cdata = NULL;
|
||||||
ctx->cdata = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->userFunc(ctx, 0);
|
ctx->userFunc(ctx, 0);
|
||||||
}
|
}
|
||||||
|
@ -1268,8 +1266,7 @@ static void
|
||||||
xml_cdata(void *userData, const XML_Char *s, int len)
|
xml_cdata(void *userData, const XML_Char *s, int len)
|
||||||
{
|
{
|
||||||
struct xml_ctx *ctx = (struct xml_ctx *)userData;
|
struct xml_ctx *ctx = (struct xml_ctx *)userData;
|
||||||
if (ctx->cdata)
|
free(ctx->cdata);
|
||||||
free(ctx->cdata);
|
|
||||||
ctx->cdata = xmalloc(len + 1);
|
ctx->cdata = xmalloc(len + 1);
|
||||||
strlcpy(ctx->cdata, s, len + 1);
|
strlcpy(ctx->cdata, s, len + 1);
|
||||||
}
|
}
|
||||||
|
@ -1518,9 +1515,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
|
||||||
ls->dentry_flags |= IS_DIR;
|
ls->dentry_flags |= IS_DIR;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
|
} else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
|
||||||
if (ls->dentry_name) {
|
free(ls->dentry_name);
|
||||||
free(ls->dentry_name);
|
|
||||||
}
|
|
||||||
ls->dentry_name = NULL;
|
ls->dentry_name = NULL;
|
||||||
ls->dentry_flags = 0;
|
ls->dentry_flags = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,7 @@ void path_list_clear(struct path_list *list, int free_items)
|
||||||
for (i = 0; i < list->nr; i++) {
|
for (i = 0; i < list->nr; i++) {
|
||||||
if (list->strdup_paths)
|
if (list->strdup_paths)
|
||||||
free(list->items[i].path);
|
free(list->items[i].path);
|
||||||
if (list->items[i].util)
|
free(list->items[i].util);
|
||||||
free(list->items[i].util);
|
|
||||||
}
|
}
|
||||||
free(list->items);
|
free(list->items);
|
||||||
}
|
}
|
||||||
|
|
6
refs.c
6
refs.c
|
@ -348,10 +348,8 @@ void unlock_ref(struct ref_lock *lock)
|
||||||
if (lock->lk)
|
if (lock->lk)
|
||||||
rollback_lock_file(lock->lk);
|
rollback_lock_file(lock->lk);
|
||||||
}
|
}
|
||||||
if (lock->ref_file)
|
free(lock->ref_file);
|
||||||
free(lock->ref_file);
|
free(lock->log_file);
|
||||||
if (lock->log_file)
|
|
||||||
free(lock->log_file);
|
|
||||||
free(lock);
|
free(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue