#ifndef _MEMDEBUG_H
#define _MEMDEBUG_H 1

void *check_malloc(int size, char *file, int line);
void p_flush(void);
int mem_biggest(void);
int mem_next(void);
int mem_check(void);
void mem_kill(void);
int mem_report(void);
void mem_exit(void);

void mem_setused(int m, int  *x, char *file, int line);
void mem_setfree(int m, int *x);
int check_block(int *x, char *name);
void check_free(void *s,char *file,int line);
void *check_calloc(int number, int size,char *file,int line);
void *check_malloc2(int  size, int t,char *file, int line);
void check_free2(void *s, int t, char *file,int line);
void *check_calloc2(int  number, int  size, int t, char *file,int line);


#define mymalloc(p_Size) check_malloc(p_Size,__FILE__,__LINE__)
#define myfree(p_Size) check_free(p_Size,__FILE__,__LINE__)
#define mymalloc2(p_Size,x) check_malloc2(p_Size,x,__FILE__,__LINE__)
#define myfree2(p_Size,x) check_free2(p_Size,x,__FILE__,__LINE__)
#define mycalloc(pnum,p_Size) check_calloc(pnum,p_Size,__FILE__,__LINE__)
#define mycalloc2(pnum,p_Size,ttt) check_calloc2(pnum,p_Size,ttt,__FILE__,__LINE__)


char *mystrdup(char *s, int type);
int mystrfree(char *s, int type);
enum {
	SD_GROUP
	,SD_LIB
	,SD_STATUS
	,SD_IGNORE
	,SD_DB
	,SD_FILTER
	,SD_DOM
	,SD_TOMAIL
	,SD_NCMD
	,SD_NNTP
	,SD_GETMAIL
	,SD_HIST
	,SD_USER
	,SD_FEED
	,SD_CHAN
	,SD_SARY
	,SD_PARTS
	,SD_HEADER
	,SD_ITEM
	,SD_FILTER2
	,SD_EXPIRE
	,SD_ML
	,SD_SUCK
	,SD_XMIT
	,SD_CMD
};
#ifdef STRDUP_MAIN
static char *strdup_names[]={
	"Group"
	,"LIB"
	,"STATUS"
	,"IGNORE"
	,"DB"
	,"FILTER"
	,"DOM"
	,"TOMAIL"
	,"NCMD"
	,"NNTP"
	,"GETMAIL"
	,"HIST"
	,"USER"
	,"FEED"
	,"CHAN"
	,"SARY"
	,"PARTS"
	,"HEADER"
	,"ITEM"
	,"FILTER2"
	,"EXPIRE"
	,"ML"
	,"SUCK"
	,"XMIT"
	,"CMD"
};
static int strdup_stats[100];
#endif

enum {
	M_XCACHE,M_HEAD,M_XWRITE
	,M_STRKEEP
	,M_BIG
	,M_XKEEP
	,M_CHAN
	,M_EMSG
	,M_DB
	,M_DIR
	,M_DBMEM
	,M_CMD
	,M_DFILTER
	,M_DOMAIN
	,M_TOMAIL
	,M_NNTP
	,M_DBF
	,M_NCMD
	,M_GETMAIL
	,M_SUCK
	,M_USER
	,M_LIB
	,M_SARY
	,M_PARTS
	,M_ITEM
	,M_FILTER
	,M_PULL
	,M_STR
	,M_EXPIRE
	,M_ML
	,M_CONTROL
	,M_MEM
	,M_GROUP
	,M_HIST
	,M_STRDUP
	,M_RAW
	,M_THIN
};
static char *m_names[]={
	"Xover Cache Str"
	,"Head Cache Str"
	,"Xover Write Str"
	,"STRKEEP"
	,"BIG Str"
	,"XKEEP"
	,"CHAN"
	,"EMSG"
	,"DB"
	,"DIR"
	,"DBMEM"
	,"CMD"
	,"DFILTER"
	,"DOMAIN"
	,"TOMAIL"
	,"NNTP"
	,"DBF"
	,"NCMD"
	,"GETMAIL"
	,"SUCK"
	,"USER"
	,"LIB"
	,"SARY"
	,"PARTS"
	,"ITEM"
	,"FILTER"
	,"PULL"
	,"STR"
	,"EXPIRE"
	,"ML"
	,"CONTROL"
	,"MEM"
	,"GROUP"
	,"HIST"
	,"STRDUP"
	,"RAW"
	,"THIN"
	,NULL
};


void mem_log(int type, int amnt);
char * mystrdup_get(int x, int *used);

#endif
