realloc.c

来自「a software code for computing selected e」· C语言 代码 · 共 29 行

C
29
字号
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <ilupack.h>#include <ilupackmacros.h>void *REALLOC(void *ptr, size_t nbytes, char *msg ){ /* allocates space -- or exits in case of     failure */  if (nbytes == 0)    return NULL;  if (ptr==NULL)     ptr = (void *) malloc(nbytes);  else     ptr = (void *) realloc(ptr,nbytes);  if (ptr == NULL) {    fprintf(stderr,"Mem. re-alloc. ERROR in %s. Requested bytes: %ld bytes\n",            msg, (long)nbytes );    fflush(stderr);     exit( -1 );  }  return ptr;}

⌨️ 快捷键说明

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