Helpful answers have been posted yet, but I want to point out that you are allocating MAX_INDEX_LENGTH * sizeof(char*) instead of MAX_INDEX_LENGTH * sizeof(char) which is what you actually want I guess.
–
Michael SchmeißerJan 28 '12 at 13:22