diff options
author | bnewbold <bnewbold@robocracy.org> | 2010-03-25 06:29:54 -0400 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2010-03-25 06:29:54 -0400 |
commit | 0bf28391b00b1e28c44324bcd7647df416314667 (patch) | |
tree | 6dda90e70218861975deb408eb21b2ff00eb5ef6 /.vim/c-support/codesnippets/calloc_double_matrix.c | |
parent | 564a2d0d39c8e1fb79ee800973848b2442833356 (diff) | |
download | openwrt-repro-0bf28391b00b1e28c44324bcd7647df416314667.tar.gz openwrt-repro-0bf28391b00b1e28c44324bcd7647df416314667.zip |
lots and lots of vim stuff for c development...
Diffstat (limited to '.vim/c-support/codesnippets/calloc_double_matrix.c')
-rw-r--r-- | .vim/c-support/codesnippets/calloc_double_matrix.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/.vim/c-support/codesnippets/calloc_double_matrix.c b/.vim/c-support/codesnippets/calloc_double_matrix.c new file mode 100644 index 0000000..ec71658 --- /dev/null +++ b/.vim/c-support/codesnippets/calloc_double_matrix.c @@ -0,0 +1,36 @@ + +/* + * === FUNCTION ====================================================================== + * Name: calloc_double_matrix + * Description: Allocate a dynamic double-matrix of size rows*columns; + * return a pointer. + * ===================================================================================== + */ + double** +calloc_double_matrix ( int rows, int columns ) +{ + int i; + double **m; + m = calloc ( rows, sizeof(double*) ); /* allocate pointer array */ + assert( m != NULL); /* abort if allocation failed */ + *m = calloc ( rows*columns, sizeof(double) );/* allocate data array */ + assert(*m != NULL); /* abort if allocation failed */ + for ( i=1; i<rows; i+=1 ) /* set pointers */ + m[i] = m[i-1] + columns; + return m; +} /* ---------- end of function calloc_double_matrix ---------- */ + +/* + * === FUNCTION ====================================================================== + * Name: free_matrix_double + * Description: Free a dynamic double-matrix. + * ===================================================================================== + */ + void +free_double_matrix ( double **m ) +{ + free(*m); /* free data array */ + free( m); /* free pointer array */ + return ; +} /* ---------- end of function free_double_matrix ---------- */ + |