From 21ffbb062e903b7cc150d87ba7d4061266d17435 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Wed, 9 Dec 2015 21:02:49 +0100 Subject: [PATCH] also free objects for haslicense and hasreadme checks, cleanup --- urmoms.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/urmoms.c b/urmoms.c index 5246cd2..01aebb1 100644 --- a/urmoms.c +++ b/urmoms.c @@ -539,7 +539,7 @@ writefiles(FILE *fp) int main(int argc, char *argv[]) { - git_object *obj = NULL; + git_object *obj_license = NULL, *obj_readme = NULL; const git_error *e = NULL; FILE *fp, *fpread; char path[PATH_MAX], *p; @@ -579,17 +579,17 @@ main(int argc, char *argv[]) } /* check LICENSE */ - haslicense = !git_revparse_single(&obj, repo, "HEAD:LICENSE"); + haslicense = !git_revparse_single(&obj_license, repo, "HEAD:LICENSE"); /* check README */ - hasreadme = !git_revparse_single(&obj, repo, "HEAD:README"); + hasreadme = !git_revparse_single(&obj_readme, repo, "HEAD:README"); /* read LICENSE */ - if (!git_revparse_single(&obj, repo, "HEAD:LICENSE")) { + if (haslicense) { fp = efopen("license.html", "w+b"); writeheader(fp); fputs("
\n", fp);
-		writeblobhtml(fp, (git_blob *)obj);
-		git_object_free(obj);
+		writeblobhtml(fp, (git_blob *)obj_license);
+		git_object_free(obj_license);
 		if (ferror(fp))
 			err(1, "fwrite");
 		fputs("
\n", fp); @@ -599,12 +599,12 @@ main(int argc, char *argv[]) } /* read README */ - if (!git_revparse_single(&obj, repo, "HEAD:README")) { + if (hasreadme) { fp = efopen("readme.html", "w+b"); writeheader(fp); fputs("
\n", fp);
-		writeblobhtml(fp, (git_blob *)obj);
-		git_object_free(obj);
+		writeblobhtml(fp, (git_blob *)obj_readme);
+		git_object_free(obj_readme);
 		if (ferror(fp))
 			err(1, "fwrite");
 		fputs("
\n", fp); -- libgit2 1.1.1