On Wed, Dec 05, 2001 at 01:35:26AM -0500, l0t3k wrote: > something that has confused me for a second is the use of HashTables to > store a user defined type. the constructor is fine, its just insertion and > querying that's mildly confusing. for instance, it seems as if > zend_hash_add takes sizeof(struct) as an argument as opposed to > sizeof(struct *) when i assume that generally we only store pointers in the > hash.
The data is actually copied. Of course it's up to you what data to store. So you can store the struct or pointer to the struct, up to you. > suppose i have a struct of type widget_t which gets allocated on the heap. > what's the general practice of inserting and retrieving widget from the hash > table ? This is probably documented at www.zend.com. You have functions for traversing it sequentially zend_hash_internal_pointer_reset(), zend_hash_get_current_data(), zend_hash_move_forward(). And you can also use zend_hash_find() and zend_hash_index_find() to use the key/index to access something. There's much more to say about this, it might be helpfull to look at the code for the array functions in ext/standard/array.c. It should be relatively easy to read the source when you know from the manual what they do. You could also look in Zend/zend_hash.h (and the .c file). Stig -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]