On Sat, 30 Nov 2002, John Coggeshall wrote:
Hey all
I was playing around and I'm running into a problem with a hashtable...
Basically, it's segfaulting my code :) Specifically, I'm trying to
return the number of items in the hash...
if(zend_hash_num_elements(hash) == 0)
Which causes the following:
Program received signal SIGSEGV, Segmentation fault.
zend_hash_num_elements (ht=0x0) at /home/php/php4/Zend/zend_hash.c:988
988 return ht-nNumOfElements;
You need to check if your ht actually is initialized, at the moment it
is NULL, and if you want to dereference that, you get a segfault.
if (!hash || (zend_hash_num_elements(hash) == 0)) {
}
should work.
Derick
--
-
Derick Rethans http://derickrethans.nl/
PHP Magazine - PHP Magazine for Professionals http://php-mag.net/
-
--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php