From: Sandro Santilli Date: Tue, 17 Feb 2015 10:23:18 +0000 (+0000) Subject: Remove use of lw_vasprintf from loader GUI X-Git-Tag: 2.2.0rc1~674 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35363430c53267af0606e54f9831e09b9bb1250f;p=postgis Remove use of lw_vasprintf from loader GUI git-svn-id: http://svn.osgeo.org/postgis/trunk@13223 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql-gui.c b/loader/shp2pgsql-gui.c index e80efe9ef..45f31514f 100644 --- a/loader/shp2pgsql-gui.c +++ b/loader/shp2pgsql-gui.c @@ -27,8 +27,6 @@ #include "shp2pgsql-core.h" #include "pgsql2shp-core.h" -#include "../liblwgeom/liblwgeom.h" /* for lw_vasprintf */ - #define GUI_RCSID "shp2pgsql-gui $Revision$" #define SHAPEFIELDMAXWIDTH 60 @@ -206,7 +204,8 @@ enum }; /* Other */ -static char *pgui_errmsg = NULL; +#define GUIMSG_LINE_MAXLEN 256 +static char *pgui_errmsg[GUIMSG_LINE_MAXLEN+1]; static PGconn *pg_connection = NULL; static SHPCONNECTIONCONFIG *conn = NULL; static SHPLOADERCONFIG *global_loader_config = NULL; @@ -224,10 +223,11 @@ static void pgui_sanitize_connection_string(char *connection_string); void pgui_log_va(const char *fmt, va_list ap) { - char *msg; + char *msg[GUIMSG_LINE_MAXLEN+1]; GtkTextIter iter; - if (!lw_vasprintf (&msg, fmt, ap)) return; + if ( -1 == vsnprintf (msg, GUIMSG_LINE_MAXLEN, fmt, ap) ) return; + msg[GUIMSG_LINE_MAXLEN] = '\0'; /* Append text to the end of the text area, scrolling if required to make it visible */ gtk_text_buffer_get_end_iter(textbuffer_log, &iter); @@ -239,9 +239,6 @@ pgui_log_va(const char *fmt, va_list ap) /* Allow GTK to process events */ while (gtk_events_pending()) gtk_main_iteration(); - - free(msg); - return; } /* @@ -263,11 +260,8 @@ pgui_logf(const char *fmt, ...) void pgui_seterr_va(const char *fmt, va_list ap) { - /* Free any existing message */ - if (pgui_errmsg) - free(pgui_errmsg); - - if (!lw_vasprintf (&pgui_errmsg, fmt, ap)) return; + if ( -1 == vsnprintf (pgui_errmsg, GUIMSG_LINE_MAXLEN, fmt, ap) ) return; + pgui_errmsg[GUIMSG_LINE_MAXLEN] = '\0'; } static void