]> granicus.if.org Git - postgis/commitdiff
Remove use of lw_vasprintf from libpgcommon
authorSandro Santilli <strk@keybit.net>
Tue, 17 Feb 2015 10:03:47 +0000 (10:03 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 17 Feb 2015 10:03:47 +0000 (10:03 +0000)
Drops useless heap allocations

git-svn-id: http://svn.osgeo.org/postgis/trunk@13220 b70326c6-7e19-0410-871a-916f4a2858ee

libpgcommon/lwgeom_pg.c

index 5b73f6280c43b7d5894036abbe7e48617cfba24e..e01af4c14c04ae28c82a2d743b3cd66c78f87563 100644 (file)
@@ -29,6 +29,8 @@
 
 #define PARANOIA_LEVEL 1
 
+#define PGC_ERRMSG_MAXLEN 256
+
 /**
 * Utility to convert cstrings to textp pointers 
 */
@@ -152,32 +154,23 @@ pg_free(void *ptr)
 static void
 pg_error(const char *fmt, va_list ap)
 {
-#define ERRMSG_MAXLEN 256
-
-       char errmsg[ERRMSG_MAXLEN+1];
+       char errmsg[PGC_ERRMSG_MAXLEN+1];
 
-       vsnprintf (errmsg, ERRMSG_MAXLEN, fmt, ap);
+       vsnprintf (errmsg, PGC_ERRMSG_MAXLEN, fmt, ap);
 
-       errmsg[ERRMSG_MAXLEN]='\0';
+       errmsg[PGC_ERRMSG_MAXLEN]='\0';
        ereport(ERROR, (errmsg_internal("%s", errmsg)));
 }
 
 static void
 pg_notice(const char *fmt, va_list ap)
 {
-       char *msg;
+       char errmsg[PGC_ERRMSG_MAXLEN+1];
 
-       /*
-        * This is a GNU extension.
-        * Dunno how to handle errors here.
-        */
-       if (!lw_vasprintf (&msg, fmt, ap))
-       {
-               va_end (ap);
-               return;
-       }
-       ereport(NOTICE, (errmsg_internal("%s", msg)));
-       free(msg);
+       vsnprintf (errmsg, PGC_ERRMSG_MAXLEN, fmt, ap);
+
+       errmsg[PGC_ERRMSG_MAXLEN]='\0';
+       ereport(NOTICE, (errmsg_internal("%s", errmsg)));
 }
 
 void