cgma
MemoryBlock Class Reference

#include <MemoryBlock.hpp>

List of all members.

Public Member Functions

 MemoryBlock (MemoryBlock *Head, char *Block, int Size)
 ~MemoryBlock ()
int get_memory_allocation ()
MemoryBlocknext_block () const
void next_block (MemoryBlock *next_block)
int block_size () const
char * get_block () const

Private Attributes

char * block
int size
MemoryBlocknext

Detailed Description

Definition at line 15 of file MemoryBlock.hpp.


Constructor & Destructor Documentation

MemoryBlock::MemoryBlock ( MemoryBlock Head,
char *  Block,
int  Size 
) [inline]

Definition at line 28 of file MemoryBlock.hpp.

    : block(Block), size(Size), next(Head) {}

Definition at line 13 of file MemoryBlock.cpp.

{
  delete [] block;
  if (next) 
  {
    delete next;
    next = NULL;
  }
}

Member Function Documentation

int MemoryBlock::block_size ( ) const [inline]

Definition at line 59 of file MemoryBlock.hpp.

{
  return size;
}
char * MemoryBlock::get_block ( ) const [inline]

Definition at line 64 of file MemoryBlock.hpp.

{
  return block;
}

Definition at line 25 of file MemoryBlock.cpp.

{
  MemoryBlock* block_ptr = this;

  // sum all allocated memory

  int amount = 0;
  while (block_ptr)
  {
    amount += block_ptr->size;
    block_ptr = block_ptr->next;
  }

  return amount;
}
MemoryBlock * MemoryBlock::next_block ( ) const [inline]

Definition at line 49 of file MemoryBlock.hpp.

{
  return next;
}
void MemoryBlock::next_block ( MemoryBlock next_block) [inline]

Definition at line 54 of file MemoryBlock.hpp.

{
  next = nxt_blck;
}

Member Data Documentation

char* MemoryBlock::block [private]

Definition at line 19 of file MemoryBlock.hpp.

Definition at line 21 of file MemoryBlock.hpp.

int MemoryBlock::size [private]

Definition at line 20 of file MemoryBlock.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines