#ifndef DWR_MEMORY_H
#define DWR_MEMORY_H

/*****************************************************************************
 *
 *  Memory.a
 *
 *  Memory allocation routines.
 */

extern UBYTE * __asm Malloc(register __d0 ULONG);
extern UBYTE * __asm Calloc(register __d0 ULONG, register __d1 ULONG);
extern VOID    __asm Free(register __a1 UBYTE *);

extern UBYTE * __asm AllocMA(register __d0 ULONG, register __d1 ULONG);
extern VOID    __asm FreeMA(register __a1 UBYTE *);
extern VOID          FreeMAll(VOID);

typedef struct MemABlock{
  ULONG                  Size;
  struct MemABlock      *Succ;
  struct MemABlock      *Pred;
  UBYTE                  Block[1];
} MABLK;

/*
 * If no block could be allocated, YOUR routine NoMem() is called.  Do what
 * ever you think is appropriate, like printing a message.  If you return 0,
 * the allocator (Malloc(), Calloc(), AllocMA()) returns 0.  If you return
 * -1, the allocator does a retry, and any other value is used as a pointer
 * to a block of the requested type and size.  Be aware that it is linked in
 * the memory list and that it will be freed by a call to FreeMAll().
 */

extern UBYTE *NoMem(ULONG Size, ULONG Type);

#endif
