Ver código fonte

Fix memory leak
Cleanup


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@34411 15284696-431f-4ddb-bdfa-cd5b030d7da7

Glynn Clements 16 anos atrás
pai
commit
7247ecdd24
1 arquivos alterados com 10 adições e 12 exclusões
  1. 10 12
      lib/proj/ellipse.c

+ 10 - 12
lib/proj/ellipse.c

@@ -197,7 +197,6 @@ struct ellps_list *read_ellipsoid_table(int fatal)
 {
     FILE *fd;
     char *file;
-    char *errbuf;
     char buf[4096];
     char name[100], descr[1024], buf1[1024], buf2[1024];
     char badlines[1024];
@@ -213,10 +212,8 @@ struct ellps_list *read_ellipsoid_table(int fatal)
 
     if (fd == NULL) {
 	perror(file);
-	G_asprintf(&errbuf, _("Unable to open ellipsoid table file <%s>"),
-		   file);
-	fatal ? G_fatal_error(errbuf) : G_warning(errbuf);
-	G_free(errbuf);
+	(fatal ? G_fatal_error : G_warning)(
+	    _("Unable to open ellipsoid table file <%s>"), file);
 	return 0;
     }
 
@@ -264,15 +261,16 @@ struct ellps_list *read_ellipsoid_table(int fatal)
 
     fclose(fd);
 
-    if (!err)
+    if (!err) {
+	G_free(file);
 	return outputlist;
+    }
 
-    G_asprintf(&errbuf,
-	       (err == 1 ? "Line%s of ellipsoid table file <%s> is invalid"
-		: "Lines%s of ellipsoid table file <%s> are invalid"),
-	       badlines, file);
-    fatal ? G_fatal_error(errbuf) : G_warning(errbuf);
-    G_free(errbuf);
+    (fatal ? G_fatal_error : G_warning)(
+	err == 1
+	? _("Line%s of ellipsoid table file <%s> is invalid")
+	: _("Lines%s of ellipsoid table file <%s> are invalid"),
+	badlines, file);
     G_free(file);
     return outputlist;
 }