On Sat, 24 Jan 2004, Adam Maccabee Trachtenberg wrote:
> On Fri, 23 Jan 2004, Marcus Boerger wrote:
>
> > Fixed too. Hey if you find some cool & easy examples please tell me.
>
> Thanks for the fix. I'll let you know when I come up with something
> cool. :)
I have another example for you to check out. This one works correctly,
but leaks memory. Assume this is setup like findfile.php:
class RegexFindFile extends FindFile {
function accept() {
return preg_match($this->file, $this->current());
}
}
foreach(new RegexFindFile($argv[1], $argv[2]) as $pathname => $file)
echo $file->getPathname()."\n";
[EMAIL PROTECTED]:~/CVS/php/php-src/ext/spl/examples] $ php ./findfile.php . '/php$/'
./dba_array.php
./dba_dump.php
./directorytree.php
./findfile.php
./ini_groups.php
./tree.php
/Users/adam/CVS/php/php-src/main/streams/streams.c(371) : Stream of
type 'dir' 0xac81d0 (path:(null)) was not closed
/Users/adam/CVS/php/php-src/main/streams/streams.c(371) : Stream of
type 'dir' 0xac74a8 (path:(null)) was not closed
/Users/adam/CVS/php/php-src/ext/spl/spl_directory.c(125) : Freeing
0x00AC7838 (6 bytes), script=./findfile.php
Last leak repeated 1 time
/Users/adam/CVS/php/php-src/main/streams/streams.c(215) : Freeing
0x00AC81D0 (132 bytes), script=./findfile.php
/Users/adam/CVS/php/php-src/main/streams/plain_wrapper.c(872) : Actual
location (location was relayed)
Last leak repeated 1 time
/Users/adam/CVS/php/php-src/ext/spl/spl_directory.c(93) : Freeing
0x00AC7D70 (1056 bytes), script=./findfile.php
Last leak repeated 1 time
/Users/adam/CVS/php/php-src/ext/spl/spl_directory.c(99) : Freeing
0x00AC7780 (32 bytes), script=./findfile.php
/Users/adam/CVS/php/php-src/Zend/zend_hash.c(157) : Actual location
(location was relayed)
Last leak repeated 1 time
/Users/adam/CVS/php/php-src/ext/spl/spl_directory.c(98) : Freeing
0x00AC7710 (44 bytes), script=./findfile.php
Last leak repeated 1 time
=== Total 10 memory leaks detected ===
-adam
--
[EMAIL PROTECTED]
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php