Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81766 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28809 invoked from network); 4 Feb 2015 06:25:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Feb 2015 06:25:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@tekwire.net; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=francois@tekwire.net; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain tekwire.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@tekwire.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:56679] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/54-20608-F4BB1D45 for ; Wed, 04 Feb 2015 01:25:20 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 848D14B0178; Wed, 4 Feb 2015 07:22:02 +0100 (CET) Reply-To: To: "'Xinchen Hui'" Cc: "'PHP Internals'" , "'Dmitry Stogov'" References: <008a01d03f06$8cae6f20$a60b4d60$@tekwire.net> In-Reply-To: Date: Wed, 4 Feb 2015 07:25:12 +0100 Message-ID: <00c001d04043$55854c10$008fe430$@tekwire.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHdbSTnoUvvQnF9fe5lyro9w/l3gAJNeAs9AQyrA1wByREj6pycjSNQ Content-Language: fr X-Antivirus: avast! (VPS 150203-1, 03/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] Re: [DICUSS]Cleanup resource handling APIs From: francois@tekwire.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) > De : Xinchen Hui [mailto:laruence@php.net] > > I don't understand how you can delete the resource if you remove the > handle from the zend_resource struct. Or would you store the index > elsewhere ? >=20 > if you use HashTable , yes, it's hard to get rid of it, but we can > hidden it from user land.. >=20 > and actually, we only use integer index of regular_list for = zend_resource.. >=20 > if we decide to remove handle, then it maybe easy to re-implement it > as a plain c array like zend_resource[]; >=20 > and when doing realloce, we allocate new segment, and link them = togther. Anyway, IMO, moving resources from HashTable to a plain C array is a = good thing. Allocating segments of 20 structs, for instance, would be = fine as a single segment would fit 99.9 % of the cases. This way, you = could even compute a pseudo resource handle from the zend_resource = address (for var_dump()). The only additional thing you would need is a = field to mark the resource as deleted/invalid. But setting ptr to NULL = and type to -1 would be probably enough. I am interested in the subject of resources because I just implemented a = resource abstraction layer in php-ext-gen = (https://github.com/flaupretre/php-ext-gen). The objective being to use = the same user code for PHP 5 and 7. Maybe you can have a look at the = project and give me your opinion. Regards Fran=C3=A7ois