📄 rtarray.h
字号:
/* * $Id: rtarray.h 1339 2006-09-21 19:46:28Z tbailey $ * * $Log$ * Revision 1.1 2005/07/29 19:10:42 nadya * Initial revision * *//********************************************************************************** Header for macros dimensioning arrays at run time.** DIM2(prow,row,col,type) - row x col array of type, prow is type **** FREE2(prow) - release storage allocated by DIM2**** Anderson, P. and Anderson, G., "Advanced C tips and techniques", Hayden Books, ** Indianapolis, pg 187, (1988)********************************************************************************/#ifndef RTARRAY_H#define RTARRAY_H/*#include <stdio.h>*/#include <stdlib.h>#define DIM2( prow, row, col, type ) { \ int irows; \ type *pdata; \ pdata = (type *) calloc( (size_t)((row) * (col)), sizeof(type) ); \ if ( pdata == (type *) NULL ) { \ fprintf(stderr, "DIM2 - failure to calloc pdata - insufficient space in heap\n" ); \ exit(1); \ } \ prow = (type **) calloc( (size_t)(row), sizeof(type *) ); \ if ( prow == (type **) NULL ) { \ fprintf(stderr, "DIM2 - failure to calloc" #prow "- insufficient space in heap\n" ); \ exit(1); \ } \ for ( irows=0; irows<row; irows++ ) { \ prow[irows] = pdata; \ pdata += col; \ } \} #define FREE2(prow) { \ free( *prow ); \ free( prow ) ; \} #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -