Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12438 closed (fixed)

use GEOSFree instead of c.free in geos binding.

Reported by: kiorky <kiorky@…> Owned by: nobody
Component: GIS Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: UI/UX:

Description

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):

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by jbronn

  • Resolution set to fixed
  • Status changed from new to closed

(In [11979]) Fixed #12438 -- now use GEOSFree to free string pointers allocated within GEOS when available; now parse out subminor version, and added a GEOS_VERSION tuple.

comment:2 Changed 4 years ago by jbronn

(In [11980]) [1.1.X] Fixed #12438 -- now use GEOSFree to free string pointers allocated within GEOS when available; now parse out subminor version, and added a GEOS_VERSION tuple.

Backport of r11979 from trunk.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.