Extension C code help please

From: Date: Tue, 13 Jul 2004 09:06:07 +0000
Subject: Extension C code help please
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-950@lists.php.net to get a copy of this message
Hello, Not sure if this is the right group to post to but I need some help on a PHP Extension that I have written. It is used to allow PHP to query VerityK2 servers and what I have done so far works, I just need to sort out a few loose ends. This bit I am stuck on is the following: CSTRING--pointer--A pointer to a null-terminated character string. Near the top of my code I define an array of CSTRINGS that will contain the field and collection names. CSTRING fieldNm[1000]; CSTRING collectionNm[1000]; I then go through an array that I pass from the PHP function call and copy the contents of each element of the array into fieldNm or collectionNm. Below is the code that copies the fields into fieldNm. for (zend_hash_internal_pointer_reset(hfields); zend_hash_get_current_data(hfields,(void**)&entry)==SUCCESS; zend_hash_move_forward(hfields)){ convert_to_string_ex(entry); fieldNm[fieldcounter]=malloc(sizeof(Z_STRVAL_PP(entry))); fieldNm[fieldcounter]=Z_STRVAL_PP(entry); fieldcounter++; } My problem is (apart from being rubbish a C) is that fieldNm's size is defined before I actually know how many elements there are. I have set it arbitrarily high to 1000 and this to work, but, it would be nice to get better I suppose. Sorry for my lack of C knowledge, I'm sure there is a easy solution to this. Thanks for any help! Chris..

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