Ticket #249 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

GEOS, Shapely, DLLs, and memory

Reported by: aronb Owned by: warmerdam
Priority: major Milestone: 3.2.0
Component: C API Version: 3.1.0
Severity: Significant Keywords: runtime heap
Cc: pramsey

Description

Add a GEOSFree function to the capi so that users can free memory allocated in the GEOS DLL from the same DLL. This is needed if the user code is using a different copy of the CRT than GEOS.

Attachments

geos.patch Download (0.9 KB) - added by aronb 3 years ago.
GEOSFree patch

Change History

Changed 3 years ago by aronb

GEOSFree patch

Changed 3 years ago by pramsey

  • owner changed from geos-devel@… to pramsey
  • status changed from new to assigned

Changed 3 years ago by mloskot

A minor impr. to the patch - missing std qualifier:

void GEOSFree (void* buffer) 
{ 
   std::free(buffer); 
}

Changed 3 years ago by warmerdam

  • status changed from assigned to new
  • severity changed from Unassigned to Significant
  • cc pramsey added
  • component changed from Default to C API
  • owner changed from pramsey to warmerdam
  • keywords runtime heap added

I have apply the change in trunk, and added a GEOSFree_r() (r2506). I don't understand the requirement for std:: qualifier and did not add it.

I would still like to backport this into the stable 3.2 and 3.0 branches but this will apparently require further discussion on the list.

Changed 3 years ago by mloskot

Frank,

The free() function is declared in <cstdlib> and this header should be included (and it is from geos_ts_c.cpp). The free() function (as all C++ free standard functions) is declared in std namespace. So, std::free() should be qualified with name of its namespace, for the same reasons why std::vector<int> but not vector<int>.

BTW, shouldn't GEOSFree delegate deallocation to GEOSFree_r?

Changed 3 years ago by warmerdam

Suggested changes made in trunk (r2507).

Changed 3 years ago by warmerdam

  • status changed from new to closed
  • resolution set to fixed

With the implicit permission on the list I have applied the changes in 3.1 branch as well (r2509).

I believe testing for a CAPI version of greater than 1.5.0 should be sufficient to know if GEOSFree() is available as part of the GEOS C API.

Note: See TracTickets for help on using tickets.