adding class members in C
| From: | Dave Viner | Date: | Wed, 12 Feb 2003 19:56:39 +0000 |
| Subject: | adding class members in C | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-94198@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to write a class as a PHP C extension. I want to add a member
variable to class declaration time. I believe this is possible by adding to
the zend_class_entry's default_properties HashTable. My attempts so far
have resulted in apache core dumps. My code for PHP_MINIT_FUNCTION look
like:
zend_class_entry MyClass_class_entry;
char *cv2;
INIT_CLASS_ENTRY(MyClass_class_entry, "MyClass",
MyClass_class_funcs);
MyClass_class_entry_ptr =
zend_register_internal_class(&MyClass_class_entry);
fprintf(stderr,"Registered class with name
'%s'\n",MyClass_class_entry_ptr->name);
zend_hash_update(&MyClass_class_entry_ptr->default_properties,
"memvar", 7,
"member value", 13,
(void **) &cv2);
fprintf(stderr,"made MyClass::memvar point to '%s'\n", cv2);
However, I get coredumps on apache startup.
What is the correct way to register member variables at class declaration
time?
thanks
dave