Re: Re: foreach segfaults on array built by extension

From: Date: Wed, 13 Apr 2005 05:39:04 +0000
Subject: Re: Re: foreach segfaults on array built by extension
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2266@lists.php.net to get a copy of this message
Sara Golemon wrote:
PHP_FUNCTION(zeroconf_test) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
      return;
}
Just a niggle, but why bother with the zpa? If you're not accepting args it'd be simpler to do nothing at all, or at most: if (ZEND_NUM_ARGS() != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many arguments passed, 0 expected"); RETURN_FALSE; }
array_init(return_value); add_next_index_stringl(return_value, "test", 4,1); add_next_index_stringl(return_value, "test", 4,1); add_next_index_stringl(return_value, "test", 4,1); }
Nothing illegal here....
$array = zeroconf_test(); foreach($array1 as $service); { echo($service . "\n"); }
Copy/Paste Issues? 1) $array and $array1 aren't the same thing :) 2) Semi-colon at the end of the foreach() statement (making the code in the braces not part of the foreach). If this is your actual code I'd wonder if maybe the reason it appears to be "segfaulting after the first iteration" is that there is no iteration, you're outputting the last element of the array (leftover in $service) and the segfault is happening somewhere in RSHUTDOWN/MSHUTDOWN/etc... -Sara Thank you. That should have been obvious. The error is elsewhere.
John

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