2009/11/12 Denis Koroskin <[email protected]>: > // untested > void mkdirRecurse(string path) { > char* buffer = alloca(path.length); > memcpy(buffer, path); > > foreach (i, c; buffer[0..path.length]) { > if (c == '/') { > buffer[i] = 0; > mkdir(buffer); > buffer[i] = '/'; > } > } > } > > There are a lot of functions that allocate without a clear reason.)
I'm pretty sure the reason is that it means library code that's easier to write, understand and maintain. But yeh, if you give me the choice of two different functions, one that allocates and one that doesn't, otherwise identical, I'll pick the non-allocating version. --bb
