[Mono-dev] [PATCH]System.IO.File.Replace

Paolo Molaro lupus at ximian.com
Thu Aug 16 11:57:08 EDT 2007


On 08/15/07 Bill Holmes wrote:
> I thought the ()'s around the return was a bit odd myself.  But since
> I did not understand why they were in the existing code I kept the
> pattern going.  I will remove them from my changes.

Thanks: new code also in the io-layer should follow the mono
conventions (we just don't usually go around and fix it to avoid losing
th history).

> As for the alloca, that too is something I refactored out of the
> CopyFile method.  I agree that can cause problems so I will look for
> an alternative.
> 
> do you think I could get away with
> int buf_size = st_src->st_blksize;
> if (buf_size > 1024)
>         buf_size = 1024;
>  char *buf = (char *) alloca (buf_size);
> 
> Or should I switch to dynamic allocation (malloc)?  Or should I use
> dynamic allocation and cap the max?

Just use malloc: the amount of memory that we'd allow to be allocated
with alloca (100-200 bytes) would be useless for this usage.
The buffer size should also have a lower and upper limit (8-64 KB
is reasonable).

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list