Registering constants to internal classes (ZE2)

From: Date: Tue, 01 Jul 2003 17:33:08 +0000
Subject: Registering constants to internal classes (ZE2)
Groups: php.internals 
Request: Send a blank email to internals+get-3089@lists.php.net to get a copy of this message
Hi, Perhaps I'm missing something, but I noticed the current ZE2 implementation doesn't seem to correctly handle constants registered to internal classes. I tracked down the cause of this problem, and finally figured out that those constants are destroyed by the ordinary zval_ptr_dtor_wrapper() at the destruction of the constant hash after the deactivation of the memory manager. Then I'm putting forward the following ideas to avoid this. 1. Unify the calls of pefree() / efree() by a function pointer followed by the actual memory block which directs to the actual free() implementation the memory block should be freed by. Here's the example stuff I'm referring to: typedef struct _memblk_t { void (*free_fn)(void *ptr); byte blk[]; } memblk_t; void efree_impl(void *ptr) { ... } void pefree_impl(void *ptr) { free(ptr); } void *pemalloc_impl(size_t sz) { return malloc(sz); } void *pemalloc(size_t sz, int persistent) { void *ptr; if (persistent) { ptr = emalloc_impl(sz + sizeof(memblk_t)); ptr->free_fn = efree_impl; } else { ptr = pemalloc_impl(sz + sizeof(memblk_t)); ptr->free_fn = pefree_impl; } return (void *)ptr->blk; } void efree(void *ptr) { memblk_t *actual_head; actual_head = (memblk_t *)((byte *)ptr - &((memblk_t *)0)->blk); actual_head->free_fn((void *)actual_head); } 2. Add some new constructors / destructors dedicated to the persistent zvals, like ALLOC_INIT_PERSISTENT_ZVAL(), persistent_zval_dtor(), or persistent_zval_ptr_dtor(). I don't like this idea though. Any opinions? Moriyoshi

« previous php.internals (#3089) next »