diff --git a/raster/loader/raster2pgsql.c b/raster/loader/raster2pgsql.c index 6e6286c04..da3b35b1f 100644 --- a/raster/loader/raster2pgsql.c +++ b/raster/loader/raster2pgsql.c @@ -2279,6 +2279,8 @@ main(int argc, char **argv) { GDALDriverH drv = NULL; char *tmp = NULL; + rt_init_allocators(); + #ifdef USE_NLS setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); diff --git a/raster/rt_core/rt_context.c b/raster/rt_core/rt_context.c index c67f3c301..104d3021e 100644 --- a/raster/rt_core/rt_context.c +++ b/raster/rt_core/rt_context.c @@ -36,14 +36,6 @@ * rt_context ******************************************************************************/ -/* Functions definitions */ -void * init_rt_allocator(size_t size); -void * init_rt_reallocator(void * mem, size_t size); -void init_rt_deallocator(void * mem); -void init_rt_errorreporter(const char * fmt, va_list ap); -void init_rt_warnreporter(const char * fmt, va_list ap); -void init_rt_inforeporter(const char * fmt, va_list ap); - /* * Default allocators * @@ -124,12 +116,12 @@ struct rt_context_t { /* Static variable, to be used for all rt_core functions */ static struct rt_context_t ctx_t = { - .alloc = init_rt_allocator, - .realloc = init_rt_reallocator, - .dealloc = init_rt_deallocator, - .err = init_rt_errorreporter, - .warn = init_rt_warnreporter, - .info = init_rt_inforeporter + .alloc = default_rt_allocator, + .realloc = default_rt_reallocator, + .dealloc = default_rt_deallocator, + .err = default_rt_error_handler, + .warn = default_rt_warning_handler, + .info = default_rt_info_handler }; @@ -170,66 +162,6 @@ rt_set_handlers(rt_allocator allocator, rt_reallocator reallocator, ctx_t.warn = warning_handler; } -/** - * Initialisation allocators - * - * These are used the first time any of the allocators are called to enable - * executables/libraries that link into raster to be able to set up their own - * allocators. This is mainly useful for older PostgreSQL versions that don't - * have functions that are called upon startup. - **/ -void * -init_rt_allocator(size_t size) -{ - rt_init_allocators(); - - return ctx_t.alloc(size); -} - -void -init_rt_deallocator(void *mem) -{ - rt_init_allocators(); - - ctx_t.dealloc(mem); -} - - -void * -init_rt_reallocator(void *mem, size_t size) -{ - rt_init_allocators(); - - return ctx_t.realloc(mem, size); -} - -void -init_rt_inforeporter(const char *fmt, va_list ap) -{ - rt_init_allocators(); - - (*ctx_t.info)(fmt, ap); -} - -void -init_rt_warnreporter(const char *fmt, va_list ap) -{ - rt_init_allocators(); - - (*ctx_t.warn)(fmt, ap); -} - - -void -init_rt_errorreporter(const char *fmt, va_list ap) -{ - rt_init_allocators(); - - (*ctx_t.err)(fmt, ap); - -} - - /** * Raster core memory management functions. diff --git a/raster/rt_pg/rtpostgis.c b/raster/rt_pg/rtpostgis.c index ed36fbe2c..3a679446b 100644 --- a/raster/rt_pg/rtpostgis.c +++ b/raster/rt_pg/rtpostgis.c @@ -381,10 +381,10 @@ _PG_init(void) { /* Install liblwgeom handlers */ pg_install_lwgeom_handlers(); - /* TODO: Install raster callbacks (see rt_init_allocators)??? */ + /* Install rtcore handlers */ + rt_init_allocators(); /* Define custom GUC variables. */ - if ( postgis_guc_find_option("postgis.gdal_datapath") ) { /* In this narrow case the previously installed GUC is tied to the callback in */