Opened 15 years ago

Closed 15 years ago

#265 closed defect (invalid)

Free the WKB-memory allocated by GEOS

Reported by: lzzgeo Owned by: pramsey
Priority: major Milestone: 3.1.1
Component: C API Version: 3.1.0rc2
Severity: Unassigned Keywords: memory free
Cc:

Description

I have programed some codes on windows XP by using VC 8.0. when I created WKB memory bolck by using GEOSGeomToWKB_buf(),and freed it by using std::free(), the application will be corrupted. the source codes like this:

LONG nSize(0);
GEOSGeometry *g1(NULL);
unsigned char * pWkb(NULL);

creating the geometry g1 ...

pWkb = GEOSGeomToWKB_buf(g1, (size_t*)&nSize);

free(pWkb); will triger some error
pWkb = NULL;

GEOSGeom_destroy(g1);

so, I think we should add a function to free memory block allocated by GEOS, like this:

add the following codes into geos_c.h:
extern void GEOS_DLL GEOS_destroy(void *p);

add the following codes into geos_c.cpp:
void GEOS_destroy(void *a) {

return std::free(a);

}

it will work pretty good!

Change History (1)

comment:1 by hobu, 15 years ago

Resolution: invalid
Status: newclosed

Duplicate #249

Note: See TracTickets for help on using tickets.