allocmfs.c
来自「NIST Handwriting OCR Testbed」· C语言 代码 · 共 39 行
C
39 行
/*# proc: allocmfs - allocates and initializes an mfs structure of a# proc: specified length.# proc: reallocmfs - reallocates an mfs structure of a# proc: specified length.*/#include <stdio.h>#include <mfs.h>MFS *allocmfs(mfslen)int mfslen;{ MFS *mfs; if((mfs = (MFS *)malloc(sizeof(MFS))) == NULL) syserr("allocmfs","malloc","mfs"); if((mfs->values = (char **)calloc(mfslen, sizeof(char *))) == NULL) syserr("allocmfs","calloc","mfs->values"); mfs->alloc = mfslen; mfs->num = 0; return(mfs);}MFS *reallocmfs(mfs, newlen)MFS *mfs; int newlen;{ if (mfs == NULL || mfs->alloc == 0) return allocmfs(newlen); if ((mfs->values = (char **)realloc(mfs->values, newlen * sizeof(char *))) == NULL) fatalerr("reallocmfs", "realloc", "space for increased mfs->values"); mfs->alloc = newlen; return(mfs);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?