"Fossies" - the Fresh Open Source Software Archive

Member "heaplayers-351/allocators/fragmentation/shrinkbrkheap.h" (1 Nov 2004, 503 Bytes) of package /linux/misc/old/heaplayers_3_5_1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "shrinkbrkheap.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef _SHRINKBRKHEAP_H_
    2 #define _SHRINKBRKHEAP_H_
    3 
    4 namespace HL {
    5 
    6 //class ShrinkBrkHeap: shrink current break when free object is at the end of heap
    7 template<class SuperHeap>
    8 class ShrinkBrkHeap : public SuperHeap {
    9   public:
   10 
   11     inline void free(void * ptr) {
   12         size_t size = getSize(ptr);
   13 
   14         if (shrink_brk(getHeader(ptr), size + sizeof(Header))) {
   15             setSize(ptr, 0);
   16             markInUse(ptr);
   17         }
   18         else {
   19             SuperHeap::free(ptr);
   20         }
   21     }
   22 
   23 };  //end of class ShrinkBrkHeap
   24 
   25 };  //end of namespace HL
   26 
   27 #endif