Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::TupleList::buffer Class Reference

#include <TupleList.hpp>

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 90 of file TupleList.hpp.

Constructor & Destructor Documentation

◆ buffer() [1/2]

moab::TupleList::buffer::buffer ( size_t  sz)

Constructor which sets an initial capacity of the buffer

Definition at line 23 of file TupleList.cpp.

24 {
25  ptr = NULL;
26  buffSize = 0;
27  this->buffer_init_( sz, __FILE__ );
28 }

References buffer_init_(), buffSize, and ptr.

◆ buffer() [2/2]

moab::TupleList::buffer::buffer ( )

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

Definition at line 30 of file TupleList.cpp.

31 {
32  buffSize = 0;
33  ptr = NULL;
34 }

◆ ~buffer()

moab::TupleList::buffer::~buffer ( )
inline

Definition at line 104 of file TupleList.hpp.

105  {
106  this->reset();
107  };

References reset().

Member Function Documentation

◆ buffer_init_()

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

Initializes the buffer to have a capacity of size

Definition at line 36 of file TupleList.cpp.

37 {
38  this->buffSize = sizeIn;
39  void* res = malloc( this->buffSize );
40  if( !res && buffSize > 0 ) fail( "%s: allocation of %d bytes failed\n", file, (int)buffSize );
41  ptr = (char*)res;
42 }

References moab::fail().

Referenced by buffer().

◆ buffer_reserve_()

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 44 of file TupleList.cpp.

45 {
46  if( this->buffSize < min )
47  {
48  size_t newSize = this->buffSize;
49  newSize += newSize / 2 + 1;
50  if( newSize < min ) newSize = min;
51  void* res = realloc( ptr, newSize );
52  if( !res && newSize > 0 ) fail( "%s: reallocation of %d bytes failed\n", file, newSize );
53  ptr = (char*)res;
54  this->buffSize = newSize;
55  }
56 }

References moab::fail().

◆ reset()

Member Data Documentation

◆ buffSize

size_t moab::TupleList::buffer::buffSize

Definition at line 93 of file TupleList.hpp.

Referenced by buffer().

◆ ptr

char* moab::TupleList::buffer::ptr

Definition at line 94 of file TupleList.hpp.

Referenced by buffer(), and moab::TupleList::sort().


The documentation for this class was generated from the following files: