Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26771 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86991 invoked by uid 1010); 3 Dec 2006 10:56:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 86976 invoked from network); 3 Dec 2006 10:56:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Dec 2006 10:56:10 -0000 Authentication-Results: pb1.pair.com smtp.mail=antony@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=antony@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: antony@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:20115] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/E1-04825-62DA2754 for ; Sun, 03 Dec 2006 05:56:10 -0500 Received: (qmail 7567 invoked from network); 3 Dec 2006 10:54:04 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 3 Dec 2006 10:54:04 -0000 Message-ID: <4572AD22.7070005@zend.com> Date: Sun, 03 Dec 2006 13:55:30 +0300 User-Agent: Thunderbird 1.5.0.7 (X11/20060909) MIME-Version: 1.0 To: Alexey Zakhlestin CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] persistent memory management From: antony@zend.com (Antony Dovgal) On 12/02/2006 11:07 PM, Alexey Zakhlestin wrote: > Hi. > > I am trying to make my first php extension :) > I am sorry, if the question would be too newbiesh, but I just couldn't > find a more correct place to ask No need to use _exists here, zend_hash_find() returns FAILURE if it's failed to find the value. You're doing the hash lookup twice here: if (!zend_hash_exists(ht, ns_name, ns_len + 1)) { return NULL; } zend_hash_find(ht, ns_name, ns_len + 1, (void**)&res); Just this is enough: if (zend_hash_find() == SUCCESS) { return res; } return NULL; And Andrey is right, valgrind is priceless when it comes to debugging memory errors. -- Wbr, Antony Dovgal