While the scope change is a good start the code is stull horrible. I'd be much happier to kill these static variables entirely. The buffers can just be on stack, and getprent should just get a fs_project_t to fill out passed by reference. Same for getprpathent.