summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b3c952f)
raw | patch | inline | side by side (parent: b3c952f)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 28 Aug 2006 04:19:39 +0000 (21:19 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 28 Aug 2006 04:19:39 +0000 (21:19 -0700) |
Jonas noticed some places say "if (X) free(X)" which is totally
unnecessary.
Signed-off-by: Junio C Hamano <junkio@cox.net>
unnecessary.
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-apply.c | patch | blob | history | |
builtin-fmt-merge-msg.c | patch | blob | history | |
builtin-repo-config.c | patch | blob | history | |
builtin-rev-list.c | patch | blob | history | |
config.c | patch | blob | history | |
fetch.c | patch | blob | history | |
http-fetch.c | patch | blob | history | |
http-push.c | patch | blob | history | |
path-list.c | patch | blob | history | |
refs.c | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index b47ccacc2e0618476ca4816e111a97b2c46f0f4f..1a1deaf78c61547a53bf0c3f7f1e7f37464610c5 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
return frag;
corrupt:
- if (data)
- free(data);
+ free(data);
*status_p = -1;
error("corrupt binary patch at line %d: %.*s",
linenr-1, llen-1, buffer);
printf(" %s%-*s |%5d %.*s%.*s\n", prefix,
len, name, patch->lines_added + patch->lines_deleted,
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)
index a5ed8dbbac2a1320e7cf61e16eeccdf5c5cee915..76d22b47ba2906ecb59f0d8e279cf55a80bf8c86 100644 (file)
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
for (i = 0; i < list->nr; i++) {
free(list->list[i]);
- if (list->payload[i])
- free(list->payload[i]);
+ free(list->payload[i]);
}
free(list->list);
free(list->payload);
diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index c4164802081e03c8061f77498e08dd2ca8501af7..6560cf1c2dd04a1ef047767a69a68bac794d7187 100644 (file)
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
ret = (seen == 1) ? 0 : 1;
free_strings:
- if (repo_config)
- free(repo_config);
- if (global)
- free(global);
+ free(repo_config);
+ free(global);
return ret;
}
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index bc48a3e23081264d06f2659181a19b31694dd993..7f3e1fcfb34810285815f97979e8078e2ad6209d 100644 (file)
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
free_commit_list(commit->parents);
commit->parents = NULL;
}
- if (commit->buffer) {
- free(commit->buffer);
- commit->buffer = NULL;
- }
+ free(commit->buffer);
+ commit->buffer = NULL;
}
static void process_blob(struct blob *blob,
diff --git a/config.c b/config.c
index 82b35624543a2e50d80cafab15b63df0152adbc0..d9f2b787b94f2506ff7842c1b7b06bd15342ba6f 100644 (file)
--- a/config.c
+++ b/config.c
}
ret += git_config_from_file(fn, filename);
- if (repo_config)
- free(repo_config);
+ free(repo_config);
return ret;
}
out_free:
if (0 <= fd)
close(fd);
- if (config_filename)
- free(config_filename);
+ free(config_filename);
if (lock_file) {
unlink(lock_file);
free(lock_file);
index ef60b045eaa0a55ba65499187a3aac082ffb6af2..7d3812c40606a6afad796826dd0937a92f71bc7a 100644 (file)
--- a/fetch.c
+++ b/fetch.c
if (ret)
goto unlock_and_fail;
}
- if (msg)
- free(msg);
+ free(msg);
return 0;
diff --git a/http-fetch.c b/http-fetch.c
index 7619b338feb92a431268fc5a3963415af1b53e99..6806f3678c2878d5d2550750394a998b2c5d54db 100644 (file)
--- a/http-fetch.c
+++ b/http-fetch.c
strcat(ctx->name, ".");
strcat(ctx->name, c);
- if (ctx->cdata) {
- free(ctx->cdata);
- ctx->cdata = NULL;
- }
+ free(ctx->cdata);
+ ctx->cdata = NULL;
ctx->userFunc(ctx, 0);
}
xml_cdata(void *userData, const XML_Char *s, int len)
{
struct xml_ctx *ctx = (struct xml_ctx *)userData;
- if (ctx->cdata)
- free(ctx->cdata);
+ free(ctx->cdata);
ctx->cdata = xmalloc(len + 1);
strlcpy(ctx->cdata, s, len + 1);
}
ls->dentry_flags |= IS_DIR;
}
} 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_flags = 0;
}
diff --git a/http-push.c b/http-push.c
index 04cb238e965efdff564a9b57ce1253b274268c46..7814666d8df2e202c547cf05f0768bdc3830873c 100644 (file)
--- a/http-push.c
+++ b/http-push.c
strcat(ctx->name, ".");
strcat(ctx->name, c);
- if (ctx->cdata) {
- free(ctx->cdata);
- ctx->cdata = NULL;
- }
+ free(ctx->cdata);
+ ctx->cdata = NULL;
ctx->userFunc(ctx, 0);
}
xml_cdata(void *userData, const XML_Char *s, int len)
{
struct xml_ctx *ctx = (struct xml_ctx *)userData;
- if (ctx->cdata)
- free(ctx->cdata);
+ free(ctx->cdata);
ctx->cdata = xmalloc(len + 1);
strlcpy(ctx->cdata, s, len + 1);
}
ls->dentry_flags |= IS_DIR;
}
} 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_flags = 0;
}
diff --git a/path-list.c b/path-list.c
index f15a10de37bc453c3b495ef8b3d3046d3611ce2f..b1ee72d1dc25085f2114748001d21e3e518e54ee 100644 (file)
--- a/path-list.c
+++ b/path-list.c
for (i = 0; i < list->nr; i++) {
if (list->strdup_paths)
free(list->items[i].path);
- if (list->items[i].util)
- free(list->items[i].util);
+ free(list->items[i].util);
}
free(list->items);
}
index e70ef0ae0fe58671a35b71a55fbf81425ee84581..aab14fc107353099756403c1bf08a0786e184d98 100644 (file)
--- a/refs.c
+++ b/refs.c
if (lock->lk)
rollback_lock_file(lock->lk);
}
- if (lock->ref_file)
- free(lock->ref_file);
- if (lock->log_file)
- free(lock->log_file);
+ free(lock->ref_file);
+ free(lock->log_file);
free(lock);
}