/*
 * memoryleak.h
 * Copyright (C) Steffen Pohle 2009 <steffen@gulpe.de>
 * 
 * main.c is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * main.c is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _MEMORYLEAK_C_
#define _MEMORYLEAK_C_

#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE)
  #define ML_BT_SIZE 8
  #define ML_BT_TEXT 100
  #define MEMORYLEAK_MAX 50000
  #define MEMORYLEAK_MAXMEM 1500000000
#else
  #define ML_BT_SIZE 2
  #define ML_BT_TEXT 8
  #define MEMORYLEAK_MAX 500
  #define MEMORYLEAK_MAXMEM 8000000
#endif


struct memoryleak_data {
	int size;
	void *ptr;
	char btstr[ML_BT_SIZE][ML_BT_TEXT];
	char text[ML_BT_TEXT];
	int btcnt;
};

struct memoryleak_info {
	unsigned long int size;
	unsigned int blocks;
};

extern void ml_init ();
extern void ml_get_stats (struct memoryleak_info *m);
extern void ml_debug ();
extern void ml_addinfo (void *ptr, char *text);

extern void *ml_calloc(size_t nmemb, size_t size);
extern void *ml_malloc(size_t size);
extern void ml_free(void *ptr);
extern void *ml_realloc(void *ptr, size_t size);

#endif
