view CbC-examples/matrix/matrix.c @ 44:a14cd9f25ac4

merge.
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Mon, 25 Jan 2010 17:27:45 +0900
parents 9e4f9e20b8f1
children
line wrap: on
line source

#include "matrix.h"

void
*create_matrix(size_t size, int row, int col)
{
	int i;
	void *body;
	void **ret;

	ret = malloc( size*row*col + sizeof(void*)*row );
	if (ret==NULL) return NULL;

	body = (void*)(ret+row);
	for( i=0; i<row; i++){
		ret[i] = body + size*col*i;
	}
	return ret;
}