PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 355 of file lwgeom_geos_prepared.c.

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

356 {
357  PrepGeomHashEntry* pghe = 0;
358  PrepGeomCache* prepcache = (PrepGeomCache*)cache;
359 
360  if ( ! prepcache )
361  return LW_FAILURE;
362 
363  /*
364  * Clear out the references to the soon-to-be-freed GEOS objects
365  * from the callback hash entry
366  */
367  pghe = GetPrepGeomHashEntry(prepcache->context_callback);
368  if ( ! pghe )
369  {
370  lwerror("PrepGeomCacheCleaner failed to find hash entry for context %p", prepcache->context_callback);
371  return LW_FAILURE;
372  }
373  pghe->geom = 0;
374  pghe->prepared_geom = 0;
375 
376  /*
377  * Free the GEOS objects and free the index tree
378  */
379  POSTGIS_DEBUGF(3, "PrepGeomCacheFreeer: freeing %p argnum %d", prepcache, prepcache->argnum);
380  GEOSPreparedGeom_destroy( prepcache->prepared_geom );
381  GEOSGeom_destroy( (GEOSGeometry *)prepcache->geom );
382  prepcache->argnum = 0;
383  prepcache->prepared_geom = 0;
384  prepcache->geom = 0;
385 
386  return LW_SUCCESS;
387 }
const GEOSPreparedGeometry * prepared_geom
#define LW_SUCCESS
Definition: liblwgeom.h:55
#define LW_FAILURE
Definition: liblwgeom.h:54
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
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: