view CbC-examples/matrix/matrix.c @ 42:9e4f9e20b8f1

add some examples.
author kent@teto.cr.ie.u-ryukyu.ac.jp
date Mon, 25 Jan 2010 17:13:59 +0900
parents
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;
}