raster GUC - boot_postgis_gdal_enabled_drivers should use TopMemoryContext instead of CurrentMemoryContext

References #3659  for trunk (PostGIS 2.4)

git-svn-id: http://svn.osgeo.org/postgis/trunk@15208 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Regina Obe 2016-10-15 21:16:04 +00:00
parent bbabfe1204
commit 037480f70b

View file

@ -132,6 +132,7 @@
#include <postgres.h> /* for palloc */
#include <fmgr.h> /* for PG_MODULE_MAGIC */
#include "utils/guc.h"
#include "utils/memutils.h"
#include "../../postgis_config.h"
#include "lwgeom_pg.h"
@ -151,6 +152,9 @@ PG_MODULE_MAGIC;
/* Module load callback */
void _PG_init(void);
/* Module unload callback */
void _PG_fini(void);
#define RT_MSG_MAXLEN 256
@ -244,6 +248,14 @@ static char *gdal_datapath = NULL;
extern char *gdal_enabled_drivers;
extern char enable_outdb_rasters;
/* ---------------------------------------------------------------- */
/* Useful variables */
/* ---------------------------------------------------------------- */
static char *env_postgis_gdal_enabled_drivers = NULL;
static char *boot_postgis_gdal_enabled_drivers = NULL;
static char *env_postgis_enable_outdb_rasters = NULL;
/* postgis.gdal_datapath */
static void
rtpg_assignHookGDALDataPath(const char *newpath, void *extra) {
@ -408,11 +420,14 @@ rtpg_assignHookEnableOutDBRasters(bool enable, void *extra) {
void
_PG_init(void) {
char *env_postgis_gdal_enabled_drivers = NULL;
char *boot_postgis_gdal_enabled_drivers = NULL;
char *env_postgis_enable_outdb_rasters = NULL;
bool boot_postgis_enable_outdb_rasters = false;
MemoryContext old_context;
/*
* Change to context for memory allocation calls like palloc() in the
* extension initialization routine
*/
old_context = MemoryContextSwitchTo(TopMemoryContext);
/*
use POSTGIS_GDAL_ENABLED_DRIVERS to set the bootValue
@ -543,8 +558,29 @@ _PG_init(void) {
);
}
/* free memory allocations */
/* Revert back to old context */
MemoryContextSwitchTo(old_context);
}
/* Module unload callback */
void
_PG_fini(void) {
MemoryContext old_context;
old_context = MemoryContextSwitchTo(TopMemoryContext);
/* Clean up */
pfree(env_postgis_gdal_enabled_drivers);
pfree(boot_postgis_gdal_enabled_drivers);
pfree(env_postgis_enable_outdb_rasters);
env_postgis_gdal_enabled_drivers = NULL;
boot_postgis_gdal_enabled_drivers = NULL;
env_postgis_enable_outdb_rasters = NULL;
/* Revert back to old context */
MemoryContextSwitchTo(old_context);
}