Re: Segfault while looping through hash table
| From: | Farley Knight | Date: | Fri, 15 May 2009 12:07:00 +0000 |
| Subject: | Re: Segfault while looping through hash table | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-43985@lists.php.net to get a copy of this message | ||
On Fri, May 15, 2009 at 12:13 AM, Moriyoshi Koizumi <mozo@mozo.jp> wrote:
> On Fri, May 15, 2009 at 12:31 PM, Farley Knight <farleyknight@gmail.com> wrote:
>
>> zend_hash_internal_pointer_reset(Z_ARRVAL(zhash));
>>
>> printf("This hash table has %d entries\n",
>> zend_hash_num_elements(Z_ARRVAL(zhash)));
>>
>> int current = 0;
>>
>> while (zend_hash_get_current_data(Z_ARRVAL(zhash), (void**)&value)
>> == SUCCESS) {
>> current++;
>> printf("Currently on entry %d\n", current);
>> if (zend_hash_move_forward(Z_ARRVAL(zhash)) == SUCCESS)
>> printf("Done moving hash forward. Result was successful\n");
>> else
>> printf("Done moving hash forward. Result was a failure\n");
>> }
>>
>
> Does the problem persist if replacing the hashtable functions by the
> _ex counterparts: zend_internal_pointer_reset_ex(),
> zend_hash_get_current_data_ex() and zend_move_forward_ex()? These are
> always recommended (I believe) because the internal HashPosition value
> associated to a hashtable is also used in the user script.
>
> Regards,
> Moriyoshi
>
Actually I believe I did, but if they are recommended, I suppose I
will use them instead. Thanks for pointing that out.
BTW I did provide a link to the rest of the code, but I realize what I
posted above might not be enough to understand where the bug lies.
Should I bother posting a larger portion?
Thanks,
- Farley