On Wednesday, April 25, 2012 11:57:34 AM UTC-5, Bram Moolenaar wrote: > Benjamin Fritz wrote in February: > > > Updated patch attached to fix that 'autochdir' causes :vimgrep to > > fail, based on 7.3.421. I did have one more question: I noticed that > > the pre-existing code dynamically allocates memory of static size > > MAXPATHL for both dirname_start and dirname_now. I have kept this and > > done the same thing for the restore_start_dir function I added, but I > > wonder, is there a reason the path string cannot be stack-allocated > > instead? Is it to limit stack size or something, since MAXPATHL can be > > somewhat large? > > Running out of stack space usually causes a nasty crash. Can't even > save the swap file then, unless the system supports a signal stack. > Therefore Vim avoids putting large buffers on the stack. MAXPATHL is > often 4000 or 8000 bytes, which is quite a lot. Especially when doing > it in many places. >
Yes, thanks for the clarification. You said earlier: > As a rule of thumb: A function should not put more than about 1000 bytes > on the stack. Les if it used recursively. That's because we can > gracefully handle out-of-memory allocations but not out-of-stack errors, > these cause a crash. As I mentioned, the patch uses the existing method of dynamically allocating MAXPATHL bytes instead of putting it on the stack; I decided it was probably done for a reason, I just wasn't sure of the reason. I was asking only for the sake of better understanding of the Vim code. This isn't holding up the patch, is it? -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
