home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_std / memory.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  98 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://SmallEiffel.loria.fr
  11. --
  12. expanded class MEMORY
  13. --
  14. -- Facilities for tuning up the garbage collection, and
  15. -- everything about memory control.
  16. --
  17.  
  18. feature -- Status Report :
  19.  
  20.    frozen collecting: BOOLEAN is
  21.          -- Is garbage collection enabled ?
  22.       do
  23.          c_inline_c("R=!gc_is_off;");
  24.       end;
  25.    
  26. feature -- Status setting :
  27.  
  28.    frozen collection_off is
  29.          -- Disable garbage collection.
  30.       do
  31.          c_inline_c("gc_is_off=1;");
  32.       end;
  33.    
  34.    frozen collection_on is
  35.          -- Enable garbage collection.
  36.       do
  37.          c_inline_c("gc_is_off=0;");
  38.       end;
  39.  
  40. feature -- Removal :
  41.  
  42.    dispose is
  43.          -- Action to be executed just before garbage collection 
  44.          -- reclaims an object.
  45.       do
  46.       end;
  47.  
  48.    frozen full_collect is
  49.          -- Force a full collection cycle if garbage collection is
  50.          -- enabled; do nothing otherwise.
  51.       do
  52.          c_inline_c("gc_start();%N");
  53.       end;
  54.  
  55. feature -- The Guru section (low level memory management) :
  56.  
  57.    pointer_size: INTEGER is
  58.          -- The size in number of bytes for a pointer.
  59.       external "SmallEiffel"
  60.       end;
  61.  
  62.    malloc(size: INTEGER): POINTER is
  63.          -- Memory allocation of `size' byte.
  64.       require
  65.          size > 0
  66.       external "C_InlineWithoutCurrent"
  67.       end;
  68.  
  69.    calloc(number_of_objects, size_of_one: INTEGER): POINTER is
  70.          -- Allocates memory for an array of `number_of_objects' elements
  71.          -- of `size_of_one' bytes each and returns a pointer to the 
  72.          -- allocated memory.
  73.          --  The memory is set to zero.
  74.       require
  75.          number_of_objects > 0;
  76.          size_of_one >= 1
  77.       external "C_InlineWithoutCurrent"
  78.       end;
  79.  
  80.    realloc(pointer: POINTER; size: INTEGER): POINTER is
  81.          -- Memory re-allocation of `size' byte.
  82.       require
  83.          pointer.is_not_null;
  84.          size > 0
  85.       external "C_InlineWithoutCurrent"
  86.       end;
  87.  
  88.    free(pointer: POINTER) is
  89.       obsolete "Since release -0.81, the Garbage Collector is %
  90.                %implemented. This feature will be soon removed."
  91.       require
  92.          pointer.is_not_null
  93.       do
  94.       end;
  95.  
  96. end -- MEMORY
  97.  
  98.