[pypy-svn] r32386 - pypy/branch/kill-keepalives/pypy/translator/c/src

arigo at codespeak.net arigo at codespeak.net
Sat Sep 16 14:43:43 CEST 2006


Author: arigo
Date: Sat Sep 16 14:43:41 2006
New Revision: 32386

Modified:
   pypy/branch/kill-keepalives/pypy/translator/c/src/mem.h
Log:
Allow raw_free(NULL), and don't count it as a free.


Modified: pypy/branch/kill-keepalives/pypy/translator/c/src/mem.h
==============================================================================
--- pypy/branch/kill-keepalives/pypy/translator/c/src/mem.h	(original)
+++ pypy/branch/kill-keepalives/pypy/translator/c/src/mem.h	Sat Sep 16 14:43:41 2006
@@ -33,7 +33,7 @@
 
 #endif
 
-#define OP_RAW_FREE(p, r) PyObject_Free(p); COUNT_FREE;
+#define OP_RAW_FREE(p, r) PyObject_Free(p); COUNT_FREE(p);
 
 #define OP_RAW_MEMCLEAR(p, size, r) memset((void*)p, 0, size)
 
@@ -97,7 +97,7 @@
 /*------------------------------------------------------------*/
 
 #define COUNT_MALLOC	/* nothing */
-#define COUNT_FREE	/* nothing */
+#define COUNT_FREE(p)	/* nothing */
 
 /*------------------------------------------------------------*/
 #else /*COUNT_OP_MALLOCS*/
@@ -106,7 +106,7 @@
 static int count_mallocs=0, count_frees=0;
 
 #define COUNT_MALLOC	count_mallocs++
-#define COUNT_FREE	count_frees++
+#define COUNT_FREE(p)	do { if (p) count_frees++; } while (0)
 
 PyObject* malloc_counters(PyObject* self, PyObject* args)
 {



More information about the Pypy-commit mailing list