MOAB: Mesh Oriented datABase  (version 5.4.1)
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

Constructor which sets an initial capacity of the buffer

Definition at line 23 of file TupleList.cpp.

References buffer_init_(), buffSize, and ptr.

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

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

Definition at line 30 of file TupleList.cpp.

{
    buffSize = 0;
    ptr      = NULL;
}

Definition at line 104 of file TupleList.hpp.

References reset().

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

References moab::fail().

Referenced by buffer().

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

References moab::fail().

{
    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;
    }
}

Member Data Documentation

Definition at line 93 of file TupleList.hpp.

Referenced by buffer().

Definition at line 94 of file TupleList.hpp.

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

List of all members.


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