﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12438	use GEOSFree instead of c.free in geos binding.	kiorky <kiorky@…>	nobody	"Idea is to have a portable use of 'free' among platforms, including cygwin.

A so called free function is done in geos, and is called 'GEOSFree'.

The patch is trivial, just use this function instead of libc.free.


{{{

diff -uNr Django-1.0.2-final/django/contrib/gis/geos/prototypes/errcheck.py Django-1.0.2-final.cygwin/django/contrib/gis/geos/prototypes/errcheck.py
--- Django-1.0.2-final/django/contrib/gis/geos/prototypes/errcheck.py   2008-11-19 06:44:22.000000000 +0100
+++ Django-1.0.2-final.cygwin/django/contrib/gis/geos/prototypes/errcheck.py    2009-12-23 20:24:42.875000000 +0100
@@ -1,9 +1,11 @@
 """"""
  Error checking functions for GEOS ctypes prototype functions.
 """"""
+import sys
 import os
-from ctypes import string_at, CDLL
+from ctypes import c_void_p, string_at, CDLL
 from ctypes.util import find_library
+from django.contrib.gis.geos.libgeos import lgeos
 from django.contrib.gis.geos.error import GEOSException

 # Getting the C library, needed to free the string pointers
@@ -14,6 +16,11 @@
     libc_name = 'libc'
 libc = CDLL(find_library(libc_name))

+free = lgeos.GEOSFree
+free.argtypes = [c_void_p]
+free.restype = None
+
+
 ### ctypes error checking routines ###
 def last_arg_byref(args):
     ""Returns the last C argument's by reference value.""
@@ -55,7 +62,7 @@
     # argument on these routines, and its needed to determine the
     # correct size.
     s = string_at(result, last_arg_byref(cargs))
-    libc.free(result)
+    free(result)
     return s

 def check_string(result, func, cargs):
@@ -64,7 +71,7 @@
     # Getting the string value at the pointer address.
     s = string_at(result)
     # Freeing the memory allocated by the GEOS library.
-    libc.free(result)
+    free(result)
     return s

 def check_zero(result, func, cargs):
}}}"		closed	GIS	1.1		fixed			Unreviewed	1	0	0	0	0	0
