Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15895 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56345 invoked by uid 1010); 7 Apr 2005 15:08:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 56330 invoked from network); 7 Apr 2005 15:08:32 -0000 Received: from unknown (HELO pb1.pair.com) (127.0.0.1) by localhost with SMTP; 7 Apr 2005 15:08:32 -0000 X-Host-Fingerprint: 202.81.246.113 246-113.netfront.net Received: from ([202.81.246.113:43691] helo=akbkhome.com) by pb1.pair.com (ecelerity HEAD r(5268)) with SMTP id 9D/02-19272-FEC45524 for ; Thu, 07 Apr 2005 11:08:32 -0400 Received: from [192.168.0.184] (helo=alanportable2.hklc.com) by akbkhome.com with esmtp (Exim 4.44) id 1DJYeF-0003Fd-1q for internals@lists.php.net; Thu, 07 Apr 2005 23:10:23 +0800 To: internals@lists.php.net Content-Type: text/plain Date: Thu, 07 Apr 2005 23:10:53 +0800 Message-ID: <1112886653.19578.3.camel@alanportable2.hklc.com> Mime-Version: 1.0 X-Mailer: Evolution 2.0.3 Content-Transfer-Encoding: 7bit X-ACL-Warn: "cleared badlog" Subject: registering object constants leaking memory. From: alan@akbkhome.com (Alan Knowles) I'm using the code below to register object constants, however I'm getting a memory leak on the line shown.. , any ideas how to avoid this? /var/svn_live/dbdo/dbdo.c(401) : Freeing 0x0860FC34 (16 bytes), script=examples/info.php #define hash_add_assoc_long(__arg, __key, __val) hash_add_assoc_long_ex(__arg, __key, strlen(__key)+1, __val) int hash_add_assoc_long_ex(HashTable *arg, char *key, uint key_len, long n) { zval *tmp; MAKE_STD_ZVAL(tmp); // <-- 401 leaking here. ZVAL_LONG(tmp, n); return zend_symtable_update(arg, key, key_len, (void *) &tmp, sizeof(zval *), NULL); } PHP_RINIT_FUNCTION(dbdo) { ..... zend_hash_init(&dbdo_class_entry_ce->constants_table, 0, NULL, NULL, 1); /* fetch all returns */ hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "OBJECTS", 0); hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "KEY_VALUE", 1); hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "VALUE", 2); hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "SINGLE", 3); /* update/delete build or use fetchedobject. */ hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "BUILD", 1); /* error constants */ hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "E_ALL", 3); hash_add_assoc_long(&(dbdo_class_entry_ce->constants_table), "E_FULL", 63); ....