Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3089 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52290 invoked from network); 1 Jul 2003 17:30:22 -0000 Received: from unknown (HELO vckyb1.nw.wakwak.com) (211.9.230.144) by pb1.pair.com with SMTP; 1 Jul 2003 17:30:22 -0000 Received: from at.wakwak.com (at.wakwak.com [211.9.230.135:25]) by vckyb1.nw.wakwak.com (Postfix) with ESMTP id D6B303FE53 for ; Wed, 2 Jul 2003 02:30:20 +0900 (JST) Received: from at.wakwak.com (z228.61-205-223.ppp.wakwak.ne.jp [61.205.223.228]) by at.wakwak.com (8.12.9/8.12.9/2003-06-03) with SMTP id h61HUKdO054864 for ; Wed, 2 Jul 2003 02:30:20 +0900 (JST) (envelope-from moriyoshi@at.wakwak.com) Date: Wed, 02 Jul 2003 02:33:08 +0900 X-Mailer: EdMax Ver2.85.3F MIME-Version: 1.0 To: php-internal Message-ID: <20030702023308lfz5Sf@at.wakwak.com> Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Registering constants to internal classes (ZE2) From: moriyoshi@at.wakwak.com (Moriyoshi Koizumi) 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