32 #ifndef Buffer_INCLUDE_ONCE 33 #define Buffer_INCLUDE_ONCE 60 VL_DEBUG_SET_OBJECT_NAME()
68 VL_DEBUG_SET_OBJECT_NAME()
101 unsigned char* tmp_ptr =
mPtr;
109 other.
mPtr = tmp_ptr;
154 memcpy(ptr,
mPtr, min);
176 mPtr = (
unsigned char*)ptr;
203 const unsigned char*
ptr()
const {
return mPtr; }
212 if ( alignment & (alignment-1))
215 size_t actual_byte_count = bytes + alignment - 1;
218 actual_byte_count +=
sizeof(int);
221 char *original_ptr =
new char[actual_byte_count];
223 if (original_ptr ==
NULL)
227 char *base_ptr = (
char *)original_ptr +
sizeof(
int);
232 unsigned long long long_long_ptr = base_ptr - (
char*)0;
233 while( long_long_ptr % alignment ) ++long_long_ptr;
234 void *aligned_ptr = (
char*)0 + long_long_ptr;
237 void *aligned_ptr = (
void *) (((
unsigned long long)base_ptr + alignment - 1) & ~((
unsigned long long)alignment - 1));
241 int delta = (int)((
char*)aligned_ptr - (
char*)original_ptr);
244 *((
int *)aligned_ptr - 1) = delta;
255 int delta = *( (
int *)ptr - 1);
258 char *original_ptr = (
char*)ptr - delta;
261 delete [] original_ptr;
void setUserAllocatedBuffer(void *ptr, size_t bytes)
Uses a user-allocated buffer as storage.
Implements a buffer whose storage is in local memory.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
EAllocationMode allocationMode() const
Visualization Library main namespace.
const unsigned char * ptr() const
Buffer(const Buffer &other)
Buffer & operator=(const Buffer &other)
EAllocationMode mAllocationMode
The base class for all the reference counted objects.
float min(float a, float b)
void setAllocationMode(EAllocationMode mode)
void resize(size_t byte_count, size_t alignment=0)
static void alignedFree(void *ptr)
static void * alignedMalloc(size_t bytes, size_t alignment)