[postgis-tickets] r14700 - #3429, directly call set_handlers for allocator initialization
Paul Ramsey
pramsey at cleverelephant.ca
Fri Feb 26 01:51:30 PST 2016
Author: pramsey
Date: 2016-02-26 01:51:29 -0800 (Fri, 26 Feb 2016)
New Revision: 14700
Modified:
trunk/raster/rt_pg/rtpostgis.c
Log:
#3429, directly call set_handlers for allocator initialization
Modified: trunk/raster/rt_pg/rtpostgis.c
===================================================================
--- trunk/raster/rt_pg/rtpostgis.c 2016-02-26 08:21:55 UTC (rev 14699)
+++ trunk/raster/rt_pg/rtpostgis.c 2016-02-26 09:51:29 UTC (rev 14700)
@@ -153,7 +153,99 @@
#define RT_MSG_MAXLEN 256
+
/* ---------------------------------------------------------------- */
+/* Memory allocation / error reporting hooks */
+/* ---------------------------------------------------------------- */
+
+static void *
+rt_pg_alloc(size_t size)
+{
+ void * result;
+
+ POSTGIS_RT_DEBUGF(5, "rt_pgalloc(%ld) called", (long int) size);
+
+ result = palloc(size);
+
+ return result;
+}
+
+static void *
+rt_pg_realloc(void *mem, size_t size)
+{
+ void * result;
+
+ POSTGIS_RT_DEBUGF(5, "rt_pg_realloc(%ld) called", (long int) size);
+
+ if (mem)
+ result = repalloc(mem, size);
+
+ else
+ result = palloc(size);
+
+ return result;
+}
+
+static void
+rt_pg_free(void *ptr)
+{
+ POSTGIS_RT_DEBUG(5, "rt_pfree called");
+ pfree(ptr);
+}
+
+static void rt_pg_error(const char *fmt, va_list ap)
+ __attribute__(( format(printf,1,0) ));
+
+static void
+rt_pg_error(const char *fmt, va_list ap)
+{
+ char errmsg[RT_MSG_MAXLEN+1];
+
+ vsnprintf (errmsg, RT_MSG_MAXLEN, fmt, ap);
+
+ errmsg[RT_MSG_MAXLEN]='\0';
+ ereport(ERROR, (errmsg_internal("%s", errmsg)));
+}
+
+static void rt_pg_notice(const char *fmt, va_list ap)
+ __attribute__(( format(printf,1,0) ));
+
+static void
+rt_pg_notice(const char *fmt, va_list ap)
+{
+ char msg[RT_MSG_MAXLEN+1];
+
+ vsnprintf (msg, RT_MSG_MAXLEN, fmt, ap);
+
+ msg[RT_MSG_MAXLEN]='\0';
+ ereport(NOTICE, (errmsg_internal("%s", msg)));
+}
+
+static void rt_pg_debug(const char *fmt, va_list ap)
+ __attribute__(( format(printf,1,0) ));
+
+static void
+rt_pg_debug(const char *fmt, va_list ap)
+{
+ char msg[RT_MSG_MAXLEN+1];
+
+ vsnprintf (msg, RT_MSG_MAXLEN, fmt, ap);
+
+ msg[RT_MSG_MAXLEN]='\0';
+ ereport(DEBUG1, (errmsg_internal("%s", msg)));
+}
+
+
+void
+rt_init_allocators(void)
+{
+ /* raster callback - install raster handlers */
+ rt_set_handlers(rt_pg_alloc, rt_pg_realloc, rt_pg_free, rt_pg_error,
+ rt_pg_debug, rt_pg_notice);
+}
+
+
+/* ---------------------------------------------------------------- */
/* PostGIS raster GUCs */
/* ---------------------------------------------------------------- */
@@ -382,7 +474,7 @@
pg_install_lwgeom_handlers();
/* Install rtcore handlers */
- rt_init_allocators();
+ rt_set_handlers(rt_pg_alloc, rt_pg_realloc, rt_pg_free, rt_pg_error, rt_pg_debug, rt_pg_notice);
/* Define custom GUC variables. */
if ( postgis_guc_find_option("postgis.gdal_datapath") )
@@ -464,93 +556,5 @@
pfree(boot_postgis_gdal_enabled_drivers);
}
-/* ---------------------------------------------------------------- */
-/* Memory allocation / error reporting hooks */
-/* TODO: reuse the ones in libpgcommon ? */
-/* ---------------------------------------------------------------- */
-static void *
-rt_pg_alloc(size_t size)
-{
- void * result;
- POSTGIS_RT_DEBUGF(5, "rt_pgalloc(%ld) called", (long int) size);
-
- result = palloc(size);
-
- return result;
-}
-
-static void *
-rt_pg_realloc(void *mem, size_t size)
-{
- void * result;
-
- POSTGIS_RT_DEBUGF(5, "rt_pg_realloc(%ld) called", (long int) size);
-
- if (mem)
- result = repalloc(mem, size);
-
- else
- result = palloc(size);
-
- return result;
-}
-
-static void
-rt_pg_free(void *ptr)
-{
- POSTGIS_RT_DEBUG(5, "rt_pfree called");
- pfree(ptr);
-}
-
-static void rt_pg_error(const char *fmt, va_list ap)
- __attribute__(( format(printf,1,0) ));
-
-static void
-rt_pg_error(const char *fmt, va_list ap)
-{
- char errmsg[RT_MSG_MAXLEN+1];
-
- vsnprintf (errmsg, RT_MSG_MAXLEN, fmt, ap);
-
- errmsg[RT_MSG_MAXLEN]='\0';
- ereport(ERROR, (errmsg_internal("%s", errmsg)));
-}
-
-static void rt_pg_notice(const char *fmt, va_list ap)
- __attribute__(( format(printf,1,0) ));
-
-static void
-rt_pg_notice(const char *fmt, va_list ap)
-{
- char msg[RT_MSG_MAXLEN+1];
-
- vsnprintf (msg, RT_MSG_MAXLEN, fmt, ap);
-
- msg[RT_MSG_MAXLEN]='\0';
- ereport(NOTICE, (errmsg_internal("%s", msg)));
-}
-
-static void rt_pg_debug(const char *fmt, va_list ap)
- __attribute__(( format(printf,1,0) ));
-
-static void
-rt_pg_debug(const char *fmt, va_list ap)
-{
- char msg[RT_MSG_MAXLEN+1];
-
- vsnprintf (msg, RT_MSG_MAXLEN, fmt, ap);
-
- msg[RT_MSG_MAXLEN]='\0';
- ereport(DEBUG1, (errmsg_internal("%s", msg)));
-}
-
-
-void
-rt_init_allocators(void)
-{
- /* raster callback - install raster handlers */
- rt_set_handlers(rt_pg_alloc, rt_pg_realloc, rt_pg_free, rt_pg_error,
- rt_pg_debug, rt_pg_notice);
-}
More information about the postgis-tickets
mailing list