PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ PrepGeomCacheCleaner()

static int PrepGeomCacheCleaner ( GeomCache *  cache)
static

This function is passed into the generic GetGeomCache function in the case of a cache miss, so that it can free the particular indexed structure being managed.

In the case of prepared geometry, we want to leave the actual PrepGeomCache allocated and in place, but ensure that the GEOS Geometry and PreparedGeometry are freed so we don't leak memory as we transition from cache hit to miss to hit, etc.

Definition at line 365 of file lwgeom_geos_prepared.c.

References PrepGeomCache::argnum, PrepGeomCache::context_callback, PrepGeomCache::geom, PrepGeomHashEntry::geom, GetPrepGeomHashEntry(), LW_FAILURE, LW_SUCCESS, PrepGeomCache::prepared_geom, and PrepGeomHashEntry::prepared_geom.

366 {
367  PrepGeomHashEntry* pghe = 0;
368  PrepGeomCache* prepcache = (PrepGeomCache*)cache;
369 
370  if ( ! prepcache )
371  return LW_FAILURE;
372 
373  /*
374  * Clear out the references to the soon-to-be-freed GEOS objects
375  * from the callback hash entry
376  */
377  pghe = GetPrepGeomHashEntry(prepcache->context_callback);
378  if ( ! pghe )
379  {
380  lwpgerror("PrepGeomCacheCleaner failed to find hash entry for context %p", prepcache->context_callback);
381  return LW_FAILURE;
382  }
383  pghe->geom = 0;
384  pghe->prepared_geom = 0;
385 
386  /*
387  * Free the GEOS objects and free the index tree
388  */
389  POSTGIS_DEBUGF(3, "PrepGeomCacheFreeer: freeing %p argnum %d", prepcache, prepcache->argnum);
390  GEOSPreparedGeom_destroy( prepcache->prepared_geom );
391  GEOSGeom_destroy( (GEOSGeometry *)prepcache->geom );
392  prepcache->argnum = 0;
393  prepcache->prepared_geom = 0;
394  prepcache->geom = 0;
395 
396  return LW_SUCCESS;
397 }
const GEOSPreparedGeometry * prepared_geom
#define LW_SUCCESS
Definition: liblwgeom.h:65
#define LW_FAILURE
Definition: liblwgeom.h:64
const GEOSPreparedGeometry * prepared_geom
const GEOSGeometry * geom
const GEOSGeometry * geom
static PrepGeomHashEntry * GetPrepGeomHashEntry(MemoryContext mcxt)
MemoryContext context_callback
Here is the call graph for this function: