home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -seriously_amiga- / programming / c / asap / memlist_.h < prev    next >
C/C++ Source or Header  |  1998-04-23  |  2KB  |  60 lines

  1. /*****************************************************************************
  2.  *                                                                           *
  3.  * ASAP - Amiga Software Authoring Platform                                  *
  4.  *                                                                           *
  5.  * Written by Laurie Perrin                                                  *
  6.  *                                                                           *
  7.  * AMemList wrapper class                                                    *
  8.  *                                                                           *
  9.  *****************************************************************************/
  10.  
  11. #ifndef ASAP_AMemList_H
  12. #define ASAP_AMemList_H
  13.  
  14. #include <New.h>
  15.  
  16. extern "C"
  17. {
  18.  #include <EXEC/Memory.h>
  19.  #include <Proto/EXEC.h>
  20. }
  21.  
  22. template <unsigned int EntryCount>
  23. class AMemList : public MemList
  24. {
  25.  public:
  26.  
  27.  LONG Entries[(EntryCount - 1) * 2];
  28.  
  29.  inline AMemList * AllocEntry();
  30.  inline void * operator new(size_t, MemList *);
  31.  inline void FreeEntry();
  32.  inline void operator delete (void *);
  33. };
  34. //----------------------------------------------------------------------------
  35. template <unsigned int EntryCount>
  36. AMemList * AMemList<EntryCount>::AllocEntry ()
  37. {
  38.  return (AMemList *) ::AllocEntry(this);
  39. }
  40. //----------------------------------------------------------------------------
  41. template <unsigned int EntryCount>
  42. void * AMemList<EntryCount>::operator new (size_t, MemList *entry)
  43. {
  44.  return (AMemList *) ::AllocEntry(entry);
  45. }
  46. //----------------------------------------------------------------------------
  47. template <unsigned int EntryCount>
  48. void AMemList<EntryCount>::FreeEntry ()
  49. {
  50.  ::FreeEntry(this);
  51. }
  52. //----------------------------------------------------------------------------
  53. template <unsigned int EntryCount>
  54. void AMemList<EntryCount>::operator delete (void *entry)
  55. {
  56.  ((AMemList *) entry)->FreeEntry();
  57. }
  58.  
  59. #endif
  60.