Rev 106: Switch to using PyMem_Malloc/Free in http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

John Arbash Meinel john at arbash-meinel.com
Fri Oct 23 04:47:36 BST 2009


At http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

------------------------------------------------------------
revno: 106
revision-id: john at arbash-meinel.com-20091023034724-fs6w0z6r2g2xk19x
parent: john at arbash-meinel.com-20091022220500-mqq2feeapg0l3zbm
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Thu 2009-10-22 22:47:24 -0500
message:
  Switch to using PyMem_Malloc/Free
-------------- next part --------------
=== modified file 'meliae/_loader.pyx'
--- a/meliae/_loader.pyx	2009-10-22 21:47:42 +0000
+++ b/meliae/_loader.pyx	2009-10-23 03:47:24 +0000
@@ -18,9 +18,8 @@
     ctypedef unsigned long size_t
     ctypedef struct PyObject:
         pass
-    void *realloc(void *, size_t)
-    void *malloc(size_t)
-    void free(void *)
+    void *PyMem_Malloc(size_t)
+    void PyMem_Free(void *)
 
     PyObject *PyDict_GetItem(object d, object key)
     int PyDict_SetItem(object d, object key, object val) except -1
@@ -67,7 +66,7 @@
     num_refs = len(refs)
     if num_refs == 0:
         return NULL
-    ref_list = <long*>malloc(sizeof(long)*(num_refs+1))
+    ref_list = <long*>PyMem_Malloc(sizeof(long)*(num_refs+1))
     ref_list[0] = num_refs
     i = 1
     for ref in refs:
@@ -168,7 +167,7 @@
 
         def __set__(self, value):
             if self._ref_list != NULL:
-                free(self._ref_list)
+                PyMem_Free(self._ref_list)
                 self._ref_list = NULL
             self._ref_list = _list_to_ref_list(value)
 
@@ -189,7 +188,7 @@
 
         def __set__(self, value):
             if self._referrer_list != NULL:
-                free(self._referrer_list)
+                PyMem_Free(self._referrer_list)
                 self._referrer_list = NULL
             self._referrer_list = _list_to_ref_list(value)
 
@@ -202,10 +201,10 @@
 
     def __dealloc__(self):
         if self._ref_list != NULL:
-            free(self._ref_list)
+            PyMem_Free(self._ref_list)
             self._ref_list = NULL
         if self._referrer_list != NULL:
-            free(self._referrer_list)
+            PyMem_Free(self._referrer_list)
             self._referrer_list = NULL
 
     def __repr__(self):



More information about the bazaar-commits mailing list