Need some help

From: Date: Fri, 25 Feb 2005 18:39:43 +0000
Subject: Need some help
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2060@lists.php.net to get a copy of this message
Hello, I'm still trying to devellop my own php extension but there are some things I can't really understand. And there isn't many documentation about this. The main problem is I use in my main function a (dynamic) binary tree. And this tree is always the same (I take the data in a file) so it's stupid to build the tree (about 2500 nodes, so 2500 "malloc") each time the function is called. So I'd like to use a global variable to store the tree and always access the same variable. But I don't understand how to use this. In the skeleton created by ext_skel, there are two places for global variables: In the .h, just after ZEND_BEGIN_MODULE_GLOBALS ("declare any global variables you may nee") Or in the .c, just after ZEND_DECLARE_MODULES_GLOBALS ("true global ressources - no need for thread safety here") Which one I must used to declare my tree ? A should I add she TSRMLS_CC after the last argument of all functions which use the tree and access the tree with MYEXTENSION_G(the_tree) ? And finally, should I malloc all the nodes with malloc or emalloc ? The second thing is related : If I put in PHP_MINIT_FUNCTION: f = fopen("log.txt", "a"); fprintf(f, "BEGIN"); flcose(f) and in PHP_MSHUTDOWN_FUNCTION: f = fopen("log.txt", "a"); fprintf(f, "END"); flcose(f) After some times, the log.txt is like that: BEGIN END END END END ... Shouldn't it be rather that ? : BEGIN END BEGIN END BEGIN END Thanks a lot if you can help me a bit

« previous php.pecl.dev (#2060) next »