> > > I think it's not a problem to upgrade default stack buffer to 4096 by > > default. > > Stack allocation is generally same speed for 256 and 4096. > > And only dynamicly allocate a buffer when desired size isn't enough. > > Something like that : > > void > > GetOpenFileName(...) > > PPCODE: > > ... > > char filename[4096]; > > > > Quick question - are you saying that this 4096 is allocated only when the > function is called? Or would it be allocated all the time? If it's the > later, why not always dynamically allocate the memory? Does it come down to > memory use VS. speed?
Yes, this 4096 is allocated only when the function is called. It's automaticly reserve space on stack. (it's only one assembler instruction). When you use malloc you call to OS for reserve memory space in HEAP. It's a longer than reserve space on stack. In this case (in GetOpenFilename context) speed difference it's not a problem (Need to wait user interact with dialog). Do, it's possible to always use safemalloc. But, for some high frequency called function, it's better to avoid safemalloc for fixed small size buffer. I arbitrary set 4096 so it's probably enough in much case when using multisel (probably more than 100 files). Laurent