Shouldn't this be `strlen(in) * 3 + 1`? Worst possible case there still needs to be room for the `\0`.