Is there another way to accomplish this using fewer mallocs?
Yes - multiply all of your dimensions together, and allocate the space in one large chunk. But remember that just getting that much memory might cause delays also - but at least all your allocation would be done in one large chunk.

Remember that when you're working with arrays, you really just have a pointer to the beginning and an offset. Let's say I have a an array of chars:
Code:
char string[80];
If I refer to "string" it's just a pointer to the beginning of the array, and is equal to &string[0]. But when I try to access string[10] or string[20], it's the same as dereferencing the pointers "string+10" or "string+20". So you could allocate a huge chunk of memory with one pointer, and then work with various arrays by using the offsets. So given your example dimensions, you could access every element by adding 1 to the offset every time. You could access each 1-d array by adding 10 every time, each 2-d array by adding 30 every time, etc... Just be very careful with your bounds.