zend_mm_set_heap()

php.internals

Brian Shire

19 years ago
It seems like zend_mm_set_heap() isn't very useful outside zend_alloc.c because the zend_mm_heap structure definition is within the zend_alloc.c file rather than zend_alloc.h. Could we move the AG () and associated structures to the header file, or perhaps I missed something? - Shire shire@facebook.com shire@php.net

Dmitry Stogov

19 years ago
You probably missed. This function can be used to substitute main PHP heap, so all emalloc() function will work with new one. Thanks. Dmitry.

Brian Shire

19 years ago
Thanks Dmitry, I think what I was going for (in a very poorly worded way) was that I'm unable to access any of the heap structure values outside of zend_alloc.c because that's where the definition resides. For example something like the following should generate a compile time error outside zend_alloc.c: zend_mm_heap *heap; heap->overflow=0; I've attached a rough patch of what I did to make this accessible outside zend_alloc.c. -shire

Dmitry Stogov

19 years ago
You are not allowed to touch zend_mm internals, but you don't need to do it. Zend_alloc.c encapsulate all internals structures so it can be changed/improved/fixed without binary compatibility break. This is one of advantages of new memory manager. BTW it allows replace storage backend (see zend_mm_startup_ex()), and usage of several heaps with provided API (without access to internals). Dmitry.