Opened 15 years ago

Closed 15 years ago

#249 closed defect (fixed)

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 (1)

geos.patch (924 bytes ) - added by aronb 15 years ago.
GEOSFree patch

Download all attachments as: .zip

Change History (7)

by aronb, 15 years ago

Attachment: geos.patch added

GEOSFree patch

comment:1 by pramsey, 15 years ago

Owner: changed from geos-devel@… to pramsey
Status: newassigned

comment:2 by mloskot, 15 years ago

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

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

comment:3 by warmerdam, 15 years ago

Cc: pramsey added
Component: DefaultC API
Keywords: runtime heap added
Owner: changed from pramsey to warmerdam
Severity: UnassignedSignificant
Status: assignednew

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.

comment:4 by mloskot, 15 years ago

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?

comment:5 by warmerdam, 15 years ago

Suggested changes made in trunk (r2507).

comment:6 by warmerdam, 15 years ago

Resolution: fixed
Status: newclosed

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.