📄 fdtd-alloc.h
字号:
#ifndef _FDTD_ALLOC_H#define _FDTD_ALLOC_H#include <stdio.h>#include <stdlib.h>/* memory allocation macros */#define ALLOC_1D(name,nx,type) \ name = (type *)calloc(nx,sizeof(type)); \ if (!name) { \ perror("ALLOC_1D"); \ fprintf(stderr, \ "Allocation failed for " #name ". Terminating...\n"); \ exit(-1); \ }#define ALLOC_2D(name,nx,ny,type) \ name = (type *)calloc((nx)*(ny),sizeof(type)); \ if (!name) { \ perror("ALLOC_2D"); \ fprintf(stderr, \ "Allocation failed for " #name ". Terminating...\n");\ exit(-1); \ }#define ALLOC_3D(name,nx,ny,nz,type) \ name = (type *)calloc((nx)*(ny)*(nz),sizeof(type)); \ if (!name) { \ perror("ALLOC_2D"); \ fprintf(stderr, \ "Allocation failed for " #name ". Terminating...\n");\ exit(-1); \ }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -