1 http://bugs.python.org/issue2422 - adaption of the patch there to honour our G_SLICE
2 --- misc/Python-2.6.1/Objects/obmalloc.c 2011-07-26 13:10:12.668380720 +0100
3 +++ misc/build/Python-2.6.1/Objects/obmalloc.c 2011-07-26 13:17:41.951444953 +0100
10 +static int running_with_system_allocator = -1;
12 +/* If we're using GCC, use __builtin_expect() to reduce overhead of
13 + the allocator checks */
14 +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
15 +# define UNLIKELY(value) __builtin_expect((value), 0)
17 +# define UNLIKELY(value) (value)
20 /* An object allocator for Python.
22 Here is an introduction to the layers of the Python memory architecture,
27 + if (UNLIKELY(running_with_system_allocator == -1))
28 + running_with_system_allocator = (getenv("G_SLICE") != NULL);
29 + if (UNLIKELY(running_with_system_allocator))
33 * Limit ourselves to PY_SSIZE_T_MAX bytes to prevent security holes.
34 * Most python internals blindly use a signed Py_ssize_t to track
36 if (p == NULL) /* free(NULL) has no effect */
39 + if (UNLIKELY(running_with_system_allocator > 0))
43 if (Py_ADDRESS_IN_RANGE(p, pool)) {
44 /* We allocated this address. */
50 /* We didn't allocate this address. */
53 @@ -1150,6 +1170,10 @@
54 if (nbytes > PY_SSIZE_T_MAX)
57 + /* Treat running_with_system_allocator == -1 the same as 0 */
58 + if (UNLIKELY(running_with_system_allocator > 0))
62 if (Py_ADDRESS_IN_RANGE(p, pool)) {
63 /* We're in charge of this block */
69 /* We're not managing this block. If nbytes <=
70 * SMALL_REQUEST_THRESHOLD, it's tempting to try to take over this
71 * block. However, if we do, we need to copy the valid data from