apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: apr_dir_remove_recursively status
Date Thu, 14 Dec 2006 14:16:37 GMT
On Thu, Dec 14, 2006 at 03:57:18PM +0200, Lucian Adrian Grijincu wrote:
> I've modified the version posted earlier(2001) by Ben Collins-Sussman in
> this way:

Hi Lucian, thanks for sending the patch in.

The way that's written has pretty bad memory consumption behaviour.  
Using stack recursion to iterate down the directory tree is not really 
going to fly; it is liable to cause a stack overflow and crash for a 
really deep directory tree.  Eating pool memory proportional to breadth 
*and* depth of the tree is not really great either.  Ideally this should 
work something like:

1. allocate a stack as char * array
2. push passed-in directory name onto stack
3. while(stack-not-empty):
 a) create subpool
 b) pop top directory off stack
 c) open directory and loop through entries:
  i) for a directory, pop it on the stack
  ii) for anything else, delete it
 d) delete subpool

(not sure whether processing the tree in FILO order or FIFO order is 
better, I'd guess FIFO)

joe

Mime
View raw message