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);
        
       ....

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to