/*
This work is part of the Core Imaging Library developed by
Visual Analytics and Imaging System Group of the Science Technology
Facilities Council, STFC

Copyright 2003 Hamish Carr
Copyright 2017 Srikanth Nagella, Edoardo Pasca

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*	74.225 Intersession 1998 					*/
/*	Debug malloc & free		 					*/
/*	Hamish Carr, 1998							*/

#include <stdio.h>
#include <stdlib.h>

#ifdef DEBUG_MALLOC
#define malloc(x) Malloc(x, __FILE__, __LINE__)
#define free(x) Free(x, __FILE__, __LINE__)
#define calloc(x, y) Calloc(x, y, __FILE__, __LINE__)
#define realloc(x, y) Realloc(x, y, __FILE__, __LINE__)

void *Malloc(size_t size, char *fileName, long fileLine);				/*	version of malloc() with debug	*/
void Free(void *ptr, char *fileName, long fileLine);					/*	version of free() with debug		*/
void *Calloc(size_t nelem, size_t size, char *fileName, long fileLine);	/*	version of calloc() with debug	*/
void *Realloc(void *ptr, size_t size, char *fileName, long fileLine);		/*	version of realloc() with debug	*/
void FreeStub(void *ptr, char *fileName, long fileLine);				/*	stub version of free() 			*/

void Malloc_Report();											/*	reports at end of program		*/
#endif
