43 #if ! defined(__EST_CHUNK_H__) 44 #define __EST_CHUNK_H__ 49 #include <sys/types.h> 56 #if defined(__INCLUDE_CHUNK_WARNINGS__) 57 # define CHUNK_WARN(WHAT) do { cerr << "chunk: " <<WHAT << "\n";} while (0) 59 # define CHUNK_WARN(WHAT) // empty 62 #define __CHUNK_INLINE_AGGRESSIVELY__ (1) 64 #if defined(__CHUNK_INLINE_AGGRESSIVELY__) 65 # define CII(BODY) BODY 93 # define MAX_CHUNK_COUNT (USHRT_MAX) 95 # define MAX_CHUNK_SIZE (INT_MAX) 107 void *
operator new (
size_t size,
size_t bytes);
108 void operator delete (
void *it);
162 int size(
void)
const {
return ptr?ptr->size:0; };
163 int shareing(
void)
const {
return ptr?(ptr->count >1):0; };
164 int count(
void)
const {
return ptr?(ptr->count):-1; };
192 if (ptr && ptr->count > 1)
194 CHUNK_WARN(
"getting writable version of shared chunk\n");
197 return ptr?&(ptr->memory[0]):(
char *)
NULL;
199 operator const char*()
const CII({
200 return ptr?&(ptr->memory[0]):(
const char *)
NULL;
202 operator const char*()
CII({
203 return ptr?&(ptr->memory[0]):(
const char *)
NULL;
207 char operator [] (
size_t i)
const {
return ptr->memory[i]; };
208 char &operator () (
size_t i)
CII({
211 CHUNK_WARN(
"getting writable version of shared chunk\n");
212 cp_make_updatable(*this);
214 return ptr->memory[i];
friend void grow_chunk(EST_ChunkPtr &shared, EST_chunk_size inuse, EST_chunk_size newsize)
EST_ChunkPtr(const EST_ChunkPtr &cp) CII(
unsigned short use_counter
friend void cp_make_updatable(EST_ChunkPtr &shared, EST_chunk_size inuse)
friend EST_ChunkPtr chunk_allocate(size_t bytes)
friend ostream & operator<<(ostream &s, const EST_Chunk &chp)
friend class EST_ChunkPtr