Author: Justin Peel <notmuchtot...@gmail.com> Branch: rgc-mem-pressure Changeset: r48158:17db19c683dd Date: 2011-10-17 13:24 -0600 http://bitbucket.org/pypy/pypy/changeset/17db19c683dd/
Log: fix to use rffi_platform correctly. thanks fijal diff --git a/pypy/module/_hashlib/interp_hashlib.py b/pypy/module/_hashlib/interp_hashlib.py --- a/pypy/module/_hashlib/interp_hashlib.py +++ b/pypy/module/_hashlib/interp_hashlib.py @@ -12,6 +12,11 @@ algorithms = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512') +# HASH_MALLOC_SIZE is the size of EVP_MD, EVP_MD_CTX plus their points. +# Used for adding memory pressure. +HASH_MALLOC_SIZE = ropenssl.EVP_MD_SIZE + ropenssl.EVP_MD_CTX_SIZE \ + + rffi.sizeof(ropenssl.EVP_MD) * 2 + class W_Hash(Wrappable): ctx = lltype.nullptr(ropenssl.EVP_MD_CTX.TO) @@ -29,7 +34,7 @@ space.wrap("unknown hash function")) ctx = lltype.malloc(ropenssl.EVP_MD_CTX.TO, flavor='raw') ropenssl.EVP_DigestInit(ctx, digest) - rgc.add_memory_pressure(ropenssl.HASH_MALLOC_SIZE + self._digest_size()) + rgc.add_memory_pressure(HASH_MALLOC_SIZE + self._digest_size()) self.ctx = ctx def __del__(self): diff --git a/pypy/rlib/ropenssl.py b/pypy/rlib/ropenssl.py --- a/pypy/rlib/ropenssl.py +++ b/pypy/rlib/ropenssl.py @@ -109,7 +109,9 @@ GENERAL_NAME_st = rffi_platform.Struct( 'struct GENERAL_NAME_st', [('type', rffi.INT), - ]) + ]) + EVP_MD_SIZE = rffi_platform.SizeOf('EVP_MD') + EVP_MD_CTX_SIZE = rffi_platform.SizeOf('EVP_MD_CTX') for k, v in rffi_platform.configure(CConfig).items(): @@ -277,19 +279,6 @@ EVP_MD_CTX_cleanup = external( 'EVP_MD_CTX_cleanup', [EVP_MD_CTX], rffi.INT, threadsafe=False) -# size of EVP_MD, EVP_MD_CTX plus their points. Used for adding -# memory pressure - -# not sure why this code does not work -#HASH_MALLOC_SIZE = rffi_platform.sizeof(EVP_MD.TO, eci) \ -# + rffi_platform.sizeof(EVP_MD_CTX.TO, eci) \ -# + rffi.sizeof(EVP_MD) + rffi.sizeof(EVP_MD_CTX) - -# but this code does -HASH_MALLOC_SIZE = EVP_MD.TO.hints['getsize']() \ - + EVP_MD_CTX.TO.hints['getsize']() \ - + rffi.sizeof(EVP_MD) + rffi.sizeof(EVP_MD_CTX) - def init_ssl(): libssl_SSL_load_error_strings() libssl_SSL_library_init() _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit