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>
This commit is contained in:
Junio C Hamano
2006-08-27 21:19:39 -07:00
parent b3c952f838
commit 4cac42b132
10 changed files with 21 additions and 44 deletions

View File

@ -1238,10 +1238,8 @@ xml_start_tag(void *userData, const char *name, const char **atts)
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);
}
@ -1268,8 +1266,7 @@ static void
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);
}
@ -1518,9 +1515,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
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;
}