diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/matrix/matrix.c	Mon Jan 25 17:13:59 2010 +0900
@@ -0,0 +1,21 @@
+#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;
+}
+
+
+