moab
moab::TupleList::buffer Class Reference

#include <TupleList.hpp>

List of all members.

Public Member Functions

 buffer (size_t sz)
 buffer ()
 ~buffer ()
void buffer_init_ (size_t sz, const char *file)
void buffer_reserve_ (size_t min, const char *file)
void reset ()

Public Attributes

size_t buffSize
char * ptr

Detailed Description

Definition at line 114 of file TupleList.hpp.


Constructor & Destructor Documentation

Constructor which sets an initial capacity of the buffer

Definition at line 21 of file TupleList.cpp.

{
  ptr = NULL;
  buffSize = 0;
  this->buffer_init_(sz, __FILE__);
}

Default constructor (Note: buffer must be initialized before use!)

Definition at line 28 of file TupleList.cpp.

{
  buffSize = 0;
  ptr = NULL;
}

Definition at line 128 of file TupleList.hpp.

{ this->reset(); };

Member Function Documentation

void moab::TupleList::buffer::buffer_init_ ( size_t  sz,
const char *  file 
)

Initializes the buffer to have a capacity of size

Definition at line 34 of file TupleList.cpp.

{
  this->buffSize = sizeIn;
  void *res = malloc(this->buffSize);
  if (!res && buffSize > 0)
    fail("%s: allocation of %d bytes failed\n", file, (int) buffSize);
  ptr = (char*) res;
}
void moab::TupleList::buffer::buffer_reserve_ ( size_t  min,
const char *  file 
)

Ensures that the buffer has at least a capacity of min

Definition at line 43 of file TupleList.cpp.

{
  if (this->buffSize < min)
  {
    size_t newSize = this->buffSize;
    newSize += newSize / 2 + 1;
    if (newSize < min)
      newSize = min;
    void *res = realloc(ptr, newSize);
    if (!res && newSize > 0)
      fail("%s: reallocation of %d bytes failed\n", file, newSize);
    ptr = (char*) res;
    this->buffSize = newSize;
  }
}

Frees any allocated memory used by the buffer

Definition at line 59 of file TupleList.cpp.

{
  free(ptr);
  ptr = NULL;
  buffSize = 0;
}

Member Data Documentation

Definition at line 117 of file TupleList.hpp.

Definition at line 118 of file TupleList.hpp.


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