Re: Serializing references - part I
| From: | Andrei Zmievski | Date: | Mon, 23 Oct 2000 13:29:50 +0000 |
| Subject: | Re: Serializing references - part I | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-35877@lists.php.net to get a copy of this message | ||
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. *