// utf-8

/*	Copyright (C) 1998-2003 Günter Woigk
	kio@little-bat.de

 	This program 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.  

 	Permission to use, copy, modify, distribute, and sell this software and
 	its documentation for any purpose is hereby granted without fee, provided
 	that the above copyright notice appear in all copies and that both that
 	copyright notice and this permission notice appear in supporting
 	documentation, and that the name of the copyright holder not be used
 	in advertising or publicity pertaining to distribution of the software
 	without specific, written prior permission.  The copyright holder makes no
 	representations about the suitability of this software for any purpose.
 	It is provided "as is" without express or implied warranty.

 	THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 	INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 	EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 	CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 	DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 	TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 	PERFORMANCE OF THIS SOFTWARE.


	kio's fast memory manager
	-------------------------

switches:
	USE_KIOS_MALLOC		enable kio's malloc replacement (default: 1=on)
	MALLOC_TEMPMEM		enable allocation in TempMem (default: 1=on)
	MALLOC_FREELISTS	number of freelists: 14 ... 18 (default: 16)
	MALLOC_OWNER		add field for owner id to every memory header (default: 0=off)
	MALLOC_STATISTICS	count requests etc. (default: 0=off)
*/


#include	"kio.h"


#ifndef	_malloc_h_
#define	_malloc_h_


#ifndef USE_KIOS_MALLOC
	#define USE_KIOS_MALLOC 	1		// default: yes
#endif

#ifndef MALLOC_TEMPMEM
	#ifdef _MACINTOSH
		#define MALLOC_TEMPMEM	1		// default: yes
	#else
		#define MALLOC_TEMPMEM	0		// does not apply
	#endif
#endif

#ifndef MALLOC_STATISTICS
	#define MALLOC_STATISTICS	0		// default: no
#endif


// Administration:
	bool	IsMem			( void* );			// is this memory allocated with new() ?
	void*	NextMem			( void* );			// get address of next allocated block

// Owner
#if MALLOC_OWNER 
	void	SetOwner		( long id );			// for subsequent new()s
	void	SetOwner		( void* mem, long id );	// for this memory block
	long	GetOwner		( void* mem );			// of this memory block
#endif

// Statistics
#if MALLOC_STATISTICS
    extern long	malloc_xrequests;	// total number of xmem requests
    extern long	malloc_xmemsize;	// memory currently allocated externally
    extern long	malloc_xmemblocks;	// number of blocks currently allocated externally

    extern long	malloc_requests;	// total number of malloc requests
    extern long	malloc_size;		// memory currently in use
    extern long	malloc_blocks;		// number of blocks currently in use

	extern long	MallocUsedBlocks();		// count of free
	extern long MallocFreeBlocks(int);
#endif




#endif

