/*
 * replacement of malloc
 */
void * xmalloc (unsigned int size, const char * file, unsigned int line)
{
	void * ptr = malloc (size);
	if (ptr != NULL) 
	{
		add_mem_info(ptr, size, file, line);
	}
	return ptr;
}
Exemple #2
0
void *xrealloc(void *ptr, size_t size, const char * file, unsigned int line)
{
	void *ptr_new = realloc(ptr, size);
	if(ptr_new != NULL)
	{
		remove_mem_info(ptr);
		add_mem_info(ptr_new, size, file, line);
	}
	return ptr_new;
}
/*
 * replacement of calloc
 */
void * xcalloc (unsigned int elements, unsigned int size, const char * file, unsigned int line)
{
	unsigned total_size;
	void * ptr = calloc(elements , size);
	if(ptr != NULL)
	{
		total_size = elements * size;
		add_mem_info (ptr, total_size, file, line);
	}
	return ptr;
}
Exemple #4
0
/*
 * replacement of malloc
 */
void * xmalloc (unsigned int size, const char * file, unsigned int line)
{
	void * ptr = malloc (size);
	if (ptr == NULL) {
		n_alloc_errors++;
	}
	else {
		n_elems_alloc++;
		add_mem_info(ptr, size, file, line);
	}
	return ptr;
}