On 09.06.2008 15:39, Michal Dziemianko wrote:
Hello,
Here: http://212.85.117.53/DIFF.txt is small patch that will speed
up following functions:
strpos,
stripos,
strrpos
strripos,
and probably some others (all that use zend_memnstr/php_memnstr
function)
The code below is definitely wrong.
The pointers (haystack_dup & needle_dup) that were freed in the previous version
are not freed anymore, but I can see that they are still allocated, so you have a memleak there.
----------------------
- efree(haystack_dup);
- efree(needle_dup);
- RETURN_FALSE;
+ /* actual search - note "p" is reused! */
+ p = strrpos_reverse_kmp( p, needle_dup, needle_len, e);
+
+ if ( p != NULL) {
+ /* if somethign was found - return offset wrt to haystack
beginning */
+ RETURN_LONG( p - haystack_dup );
+ } else {
+ /* if nothing found - return FALSE */
+ RETURN_FALSE;
+ }
}
/* }}} */
@@ -2530,11 +2550,9 @@
----------------------
--
Wbr,
Antony Dovgal
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php