xginitvar.c

来自「xgrafix 是PTSG模拟程序中的图形截面库 改版本是最新版本」· C语言 代码 · 共 61 行

C
61
字号
#include "xgrafixint.h"/****************************************************************//* Setup and malloc stuff for variable changer dealie, Payam 7.92 *//****************************************************/void ReallocateSpecials(void);void ReallocateSpecials() {  sizeOfSpecialArray += specialSizeIncrement;  if(theSpecialArray==NULL)    theSpecialArray=(SpecialType *)malloc(sizeOfSpecialArray*sizeof(SpecialType));  else    theSpecialArray=(SpecialType *)realloc(theSpecialArray,sizeOfSpecialArray*sizeof(SpecialType));  if(theSpecialArray == NULL) {    printf("Not enough memory to allocate specials\n");    exit(1);  }}void SetUpNewVar(void *spvar, char *spname, char *type){  SpecialType     SpTemp;  if (!theRunWithXFlag)    return;  SpTemp = (SpecialType) malloc(sizeof(struct special));  SpTemp->data = spvar;  strcpy(SpTemp->Varname, spname);  if (!strcmp(type, "integer"))    SpTemp->Type = INTEGER;  else if (!strcmp(type, "float"))    SpTemp->Type = FLOAT;  else if (!strcmp(type, "double"))    SpTemp->Type = DOUBLE;  else if (!strcmp(type, "char"))    SpTemp->Type = CHAR;  else {    printf("Unknown special type: %s.  Must be 'integer', 'double', 'float', or 'char'.\n", type);    free(SpTemp);    return;  }  if (numberOfSpecials == sizeOfSpecialArray)    ReallocateSpecials();  theSpecialArray[numberOfSpecials] = SpTemp;  sprintf(TclCommand,"SetUpNewVar %d \"%s\" \"%s\"\n",numberOfSpecials++,	  spname,type);  if(Tcl_Eval(interp,TclCommand)!=TCL_OK) {    printf("Error setting up variable\n");    printf("%s\n",interp->result);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?