/* Copyright 1996 Acorn Computers Ltd
 *
 * 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.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the RISCOS library for writing applications in C for RISC OS. It may be  *
 * used freely in the creation of programs for Archimedes. It should be     *
 * used with Acorn's C Compiler Release 3 or later.                         *
 *                                                                          *
 ***************************************************************************/
/*
 * Title:   heap.h
 * Purpose: provide malloc-style heap allocation in a flex block
 *
 */

# ifndef __heap_h
# define __heap_h

# ifndef __os_h
# include "os.h"
# endif


/* ---------------------------- heap_init ----------------------------------
 * Description:   Initialises the heap allocation system.
 *
 * Parameters:    BOOL heap_shrink -- if TRUE, the flex block will be shrunk
 *                                    when possible after heap_free()
 * Returns:       void.
 * Other Info:    You must call flex_init before calling this routine.
 *
 */

void heap_init(BOOL heap_shrink);


/* ---------------------------- heap_alloc ---------------------------------
 * Description:   Allocates a block of storage from the heap.
 *
 * Parameters:    unsigned int size -- size of block to be allocated
 * Returns:       pointer to allocated block (or 0 if failed).
 * Other Info:    This uses the flex module to allocate wimp-supplied heap
 *                space. If the heap moves as the result of an extension
 *                or flex can't extend the heap then 0 is returned.
 *
 */

void *heap_alloc(unsigned int size);


/* ---------------------------- heap_free ----------------------------------
 * Description:   Free previously allocated block of heap storage.
 *
 * Parameters:    void *heapptr -- pointer to block to be freed
 * Returns:       possible error condition.
 * Other Info:    none.
 *
 */

void heap_free(void *heapptr);

#endif

/* end of heap.h */