/* %Z%%M% %I% %E% */

/*
 * Copyright (c) 1990, 1991, 1995 by Wayne C. Gramlich.
 * All rights reserved.
 *
 * Permission to use, copy, modify, distribute, and sell this software
 * for any purpose is hereby granted without fee provided that the above
 * copyright notice and this permission are retained.  The author makes
 * no representations about the suitability of this software for any purpose.
 * It is provided "as is" without express or implied warranty.
 */

/* Generic heap allocator exported interface routines: */

#ifndef HEAP_EXPORTS_H
#define HEAP_EXPORTS_H

#ifndef HEAP_TYPES_H
#include "heap_types.h"
#endif

#define heap_allocate(heap, type) \
	( (type)heap_alloc(heap, sizeof *((type)0) ) )
#define heap_allocate_zeroed(heap, type) \
	( (type)heap_alloc_zeroed(heap, sizeof *((type)0) ) )

/* Routines for using a heap. */
extern Pointer	heap_alloc(Heap, int /* size */);
extern Pointer	heap_alloc_zeroed(Heap, int /* size */);
extern void	heap_free(Heap, Pointer);
extern Pointer	heap_realloc(Heap, Pointer, int /* size */);

/* Routines for creating and destroying a heap. */
extern Heap	heap_create(
				Heap_handle /* handle */,
				Heap_pointer_routine /* alloc(Heap_handle,
							int size */,
				Heap_void_routine /* free(Heap_handle,
							Pointer */,
				Heap_pointer_routine /* realloc(Heap_handle,
							Pointer, int size */
);

extern Heap	heap_standard_create(PORT_NO_ARGS);
extern Pointer	heap_standard_alloc(Heap_handle, int /* size */);
extern void	heap_standard_free(Heap_handle, Pointer);
extern Pointer	heap_standard_realloc(Heap_handle,
					       Pointer, int /* size */);

extern void	heap_free_disallowed(Heap_handle, Pointer);
extern Pointer	heap_realloc_disallowed(Heap_handle,
						 Pointer, int /* size */);

extern Pointer	heap_size_alloc(Heap_size, int);
extern Heap	heap_size_create(Heap);
extern void	heap_size_free(Heap_size, Pointer);
extern int		heap_size_get(Heap);
extern Pointer	heap_size_realloc(Heap_size, Pointer, int);

#endif /* HEAP_EXPORTS_H */

