diff options
author | Rob Austein <sra@hactrn.net> | 2012-10-11 16:46:08 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-10-11 16:46:08 +0000 |
commit | 27e46248f522430ac4d539f8b61de83b11345733 (patch) | |
tree | caf0b7805e41dec68859dc09ce40a8f998b8d595 | |
parent | 88ceb99cffe4e40b9398d321ddce58cdaea2c7e0 (diff) |
Tell OpenSSL to use Python's replacements for libc memory allocation
functions, mostly because Python says this will make our teeth whiter.
Seems to work. Back this out if it creates portability problems.
svn path=/branches/tk274/; revision=4770
-rw-r--r-- | rpkid/ext/POW.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/rpkid/ext/POW.c b/rpkid/ext/POW.c index 92ab772e..5ff31812 100644 --- a/rpkid/ext/POW.c +++ b/rpkid/ext/POW.c @@ -8392,6 +8392,24 @@ init_POW(void) PyObject *m = Py_InitModule3("_POW", pow_module_methods, pow_module__doc__); int OpenSSL_ok = 1; + /* + * Python encourages us to use these functions instead of the ones + * in libc, and OpenSSL allows us to do this. The result seems to + * work, and, in theory, gives Python's memory allocator a better + * idea of how much memory we're really using. Not sure why it + * cares, but let's try to be nice about it. + * + * Note that this must be done BEFORE anything in OpenSSL uses + * dynamic memory, and that this will probably fail in horrible ways + * without the build-time code (-Bsymbolic, etc) which isolates our + * copy of the OpenSSL code from any system shared libraries. + * Enough other things already fail in horrible ways without that + * isolation that adding one more doesn't make much difference, but + * if you tinker with the build script and start seeing nasty + * memory-related issues, this might be the cause. + */ + CRYPTO_set_mem_functions(PyMem_Malloc, PyMem_Realloc, PyMem_Free); + #define Define_Class(__type__) \ do { \ char *__name__ = strchr(__type__.tp_name, '.'); \ |