Code:
matrix = makematrix( X, Y );
Or...
Code:
makematrix( &matrix, X, Y );
...both are clear as to what they do. There's not really much difference. Inside the function it may be a bit ugly. But it doesn't have to be:
Code:
void makematrix( type ***m, size_t x, size_t y )
{
type **t;
t = malloc( sizeof(*t) * y );
if( t )
{
size_t row = y;
while( row-- )
{
t[ row ] = malloc( sizeof( **t ) * x );
}
*m = t;
}
}
That looks about right, I've been up forever. But you don't really need to actually use the third star for anything, and still be able to pass the address of a double star. (edit: bugfix with x/y-- to row-- [Z_Z])
Quzah.