[pypy-svn] pypy default: undo most of 04257ccf2c0a to hopefully fix darwin translation

etrepum commits-noreply at bitbucket.org
Tue Mar 15 19:10:19 CET 2011


Author: Bob Ippolito <bob at redivi.com>
Branch: 
Changeset: r42673:8f177a7e05f5
Date: 2011-03-15 14:10 -0400
http://bitbucket.org/pypy/pypy/changeset/8f177a7e05f5/

Log:	undo most of 04257ccf2c0a to hopefully fix darwin translation

diff --git a/pypy/rpython/memory/gc/env.py b/pypy/rpython/memory/gc/env.py
--- a/pypy/rpython/memory/gc/env.py
+++ b/pypy/rpython/memory/gc/env.py
@@ -1,7 +1,6 @@
 """
 Utilities to get environ variables and platform-specific memory-related values.
 """
-from __future__ import with_statement
 import os, sys
 from pypy.rlib.rarithmetic import r_uint
 from pypy.rlib.debug import debug_print, debug_start, debug_stop
@@ -193,8 +192,10 @@
                                sandboxsafe=True)
 
 def get_darwin_cache_size(cache_key):
-    with lltype.scoped_alloc(rffi.LONGLONGP.TO, 1) as cache_p:
-        with lltype.scoped_alloc(rffi.SIZE_TP.TO, 1) as len_p:
+    cache_p = lltype.malloc(rffi.LONGLONGP.TO, 1, flavor='raw')
+    try:
+        len_p = lltype.malloc(rffi.SIZE_TP.TO, 1, flavor='raw')
+        try:
             size = rffi.sizeof(rffi.LONGLONG)
             cache_p[0] = rffi.cast(rffi.LONGLONG, 0)
             len_p[0] = rffi.cast(rffi.SIZE_T, size)
@@ -211,6 +212,10 @@
                 if rffi.cast(rffi.LONGLONG, cache) != cache_p[0]:
                     cache = 0    # overflow!
             return cache
+        finally:
+            lltype.free(len_p, flavor='raw')
+    finally:
+        lltype.free(cache_p, flavor='raw')
 
 
 def get_L2cache_darwin():


More information about the Pypy-commit mailing list