[Python-checkins] cpython: Issue #17469: Fix _Py_GetAllocatedBlocks() and sys.getallocatedblocks() when

antoine.pitrou python-checkins at python.org
Sat Apr 6 01:15:49 CEST 2013


http://hg.python.org/cpython/rev/2bf154ca43c6
changeset: 83114:2bf154ca43c6
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Apr 06 01:15:30 2013 +0200
summary:
 Issue #17469: Fix _Py_GetAllocatedBlocks() and sys.getallocatedblocks() when running on valgrind.
files:
 Misc/NEWS | 3 +++
 Objects/obmalloc.c | 8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #17469: Fix _Py_GetAllocatedBlocks() and sys.getallocatedblocks()
+ when running on valgrind.
+
 - Issue #17619: Make input() check for Ctrl-C correctly on Windows.
 
 - Issue #17357: Add missing verbosity messages for -v/-vv that were lost during
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -778,6 +778,8 @@
 poolp next;
 uint size;
 
+ _Py_AllocatedBlocks++;
+
 #ifdef WITH_VALGRIND
 if (UNLIKELY(running_on_valgrind == -1))
 running_on_valgrind = RUNNING_ON_VALGRIND;
@@ -791,10 +793,10 @@
 * things without checking for overflows or negatives.
 * As size_t is unsigned, checking for nbytes < 0 is not required.
 */
- if (nbytes > PY_SSIZE_T_MAX)
+ if (nbytes > PY_SSIZE_T_MAX) {
+ _Py_AllocatedBlocks--;
 return NULL;
-
- _Py_AllocatedBlocks++;
+ }
 
 /*
 * This implicitly redirects malloc(0).
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /