Re: [PHP-DEV] Serializing references - part I From: Andrei Zmievski (andrei <email protected>)
Date: 10/23/00

On Sun, 22 Oct 2000, Stanislav Malyshev wrote:
> +inline int php_add_var_hash(HashTable *var_hash, zval *var, void *var_old) {
> + ulong var_no;
> + char id[sizeof(void *)*2+3];
> +
> + snprintf(id,sizeof(id)-1,"%p",var);
> + id[sizeof(id)-1]='\0';
> + if(var_old && zend_hash_find(var_hash,id,sizeof(void *)*2,var_old) == SUCCESS) {
> + return FAILURE;
> + }
> +
> + var_no = zend_hash_num_elements(var_hash)+1; /* +1 because otherwise hash will think we are trying to store NULL pointer */
> + zend_hash_add(var_hash,id,sizeof(void *)*2,&var_no,sizeof(var_no),NULL);
> + return SUCCESS;
> +}

Why not simply cast pointer to integer and use it as the key?

-Andrei
* Non-volatile, random-access, analog memory store... a book. *

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>