summaryrefslogblamecommitdiff
path: root/src/common/malloc.c
blob: ed5fb2e44c2f61421d676a8ccc4fa5def6f4bbba (plain) (tree)
1
2
3
4
                                                               

                   
                   









































                                                                                           





                                          
      
#if !defined(DMALLOC) && !defined(GCOLLECT) && !defined(BCHECK)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "malloc.h"

void* aMalloc_( size_t size, const char *file, int line, const char *func )
{
	void *ret;
	
//	printf("%s:%d: in func %s: malloc %d\n",file,line,func,size);
	ret=malloc(size);
	if(ret==NULL){
		printf("%s:%d: in func %s: malloc error out of memory!\n",file,line,func);
		exit(1);

	}
	return ret;
}
void* aCalloc_( size_t num, size_t size, const char *file, int line, const char *func )
{
	void *ret;
	
//	printf("%s:%d: in func %s: calloc %d %d\n",file,line,func,num,size);
	ret=calloc(num,size);
	if(ret==NULL){
		printf("%s:%d: in func %s: calloc error out of memory!\n",file,line,func);
		exit(1);

	}
	return ret;
}

void* aRealloc_( void *p, size_t size, const char *file, int line, const char *func )
{
	void *ret;
	
//	printf("%s:%d: in func %s: realloc %p %d\n",file,line,func,p,size);
	ret=realloc(p,size);
	if(ret==NULL){
		printf("%s:%d: in func %s: realloc error out of memory!\n",file,line,func);
		exit(1);

	}
	return ret;
}

void * _bcalloc(size_t size, size_t cnt) {
	void *ret = malloc(size * cnt);
	memset(ret, 0, size * cnt);
	return ret;
}
#endif