[Liblas-commits] r974 - branches/1.0/python/liblas

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Dec 25 23:04:56 EST 2008


Author: hobu
Date: Thu Dec 25 23:04:55 2008
New Revision: 974
URL: http://liblas.org/changeset/974

Log:
backport r971 and r972 to 1.0 branch

Modified:
   branches/1.0/python/liblas/core.py

Modified: branches/1.0/python/liblas/core.py
==============================================================================
--- branches/1.0/python/liblas/core.py	(original)
+++ branches/1.0/python/liblas/core.py	Thu Dec 25 23:04:55 2008
@@ -95,6 +95,15 @@
     free(result)
     return retval
 
+def free_returned_char_p(result, func, cargs):
+
+    size = ctypes.c_int()
+    retvalue = ctypes.string_at(result, size.value)[:]
+    free(result)
+    return retvalue
+    
+    
+
 try:
     from numpy import array, ndarray
     HAS_NUMPY = True
@@ -137,13 +146,18 @@
     return las.LAS_GetVersion()
 
 
-las.LAS_GetVersion.restype = ctypes.c_char_p
+las.LAS_GetVersion.restype = ctypes.POINTER(ctypes.c_char)
+las.LAS_GetVersion.errcheck = free_returned_char_p
+
 version = get_version()
+las.LAS_GetVersion.restype = ctypes.c_char_p
 las.LASError_GetLastErrorNum.restype = ctypes.c_int
 
-las.LASError_GetLastErrorMsg.restype = ctypes.c_char_p
+las.LASError_GetLastErrorMsg.restype = ctypes.POINTER(ctypes.c_char)
+las.LASError_GetLastErrorMsg.errcheck = free_returned_char_p
 
-las.LASError_GetLastErrorMethod.restype = ctypes.c_char_p
+las.LASError_GetLastErrorMethod.restype = ctypes.POINTER(ctypes.c_char)
+las.LASError_GetLastErrorMethod.errcheck = free_returned_char_p
 
 las.LASError_GetErrorCount.restype=ctypes.c_int
 


More information about the Liblas-commits mailing list