memalloc.h
来自「贝叶斯优化算法是一种新的演化算法」· C头文件 代码 · 共 50 行
H
50 行
#ifndef _memalloc_h_
#define _memalloc_h_
#include <stdlib.h>
#include <malloc.h>
#include <stdio.h>
// inline functions
inline void *Malloc(int x)
{
void *p;
p=malloc(x);
if (p==NULL)
{
printf("ERROR: Not enough memory (for a block of size %u)\n",x);
exit(-1);
}
return p;
}
inline void *Calloc(int x, int s)
{
void *p;
/// printf("Allocating %u blocks of length %u\n",x,s);
p=calloc(x,s);
if (p==NULL)
{
printf("ERROR: Not enough memory. (for a block of size %u)\n",x*s);
exit(-1);
}
/// cout << "Allocated..." << flush
return p;
}
inline void Free(void *x)
{
free(x);
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?