/*
    RMA memory malloc functions

    Copyright (C) 2000  Stefan Bellon

    This program 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 2 of the License, or
    (at your option) any later version.

    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.  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, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/* On RISC OS we can use the RMA as heap and not the application workspace.
   Therefore we support our own malloc() and free() functions and keep
   track of the claimed memory in a list structure.
   Define USE_RMA in order to make use of the RMA.
*/

#ifndef __RMA_MALLOC_H__
#define __RMA_MALLOC_H__

#ifdef USE_RMA

typedef struct RMA_list_t_ {
  char               *block;
  struct RMA_list_t_ *next;
} RMA_list_t;

extern RMA_list_t *RMA_list;

void *RMA_untrapped_malloc(size_t size);
void RMA_untrapped_free(void *ptr);
void *RMA_malloc(size_t size);
void *RMA_calloc(size_t n, size_t size);
void *RMA_realloc(void *ptr, size_t size);
void RMA_free(void *ptr);
void RMA_free_all(void);

#define malloc(a) RMA_malloc((a))
#define calloc(a, b) RMA_calloc((a), (b))
#define realloc(a, b) RMA_realloc((a), (b))
#define free(a) RMA_free((a))
#endif /* USE_RMA */

#endif /* __RMA_MALLOC_H__ */
