50 EST_Chunk::EST_Chunk ()
57 EST_Chunk::~EST_Chunk ()
61 cerr <<
"deleting chunk with non-zero count\n";
75 #if !defined(__CHUNK_INLINE_AGGRESSIVELY__) 77 void EST_Chunk:: operator ++ ()
82 cerr<<
"max count exceeded\n";
93 void EST_Chunk::operator -- ()
97 cerr<<
"negative count\n";
108 void *EST_Chunk::operator
new (
size_t size,
size_t bytes)
113 cerr<<
"trying to make chunk of size "<<bytes<<
"\n";
116 void *it =
walloc(
char, size+bytes);
127 void EST_Chunk::operator
delete (
void *it)
139 #if !defined(__CHUNK_INLINE_AGGRESSIVELY__) 185 EST_ChunkPtr::operator
const char*()
const 188 return &(ptr->memory[0]);
193 EST_ChunkPtr::operator
char const*()
195 return ptr?&(ptr->memory[0]):(
const char *)
NULL;
204 CHUNK_WARN(
"getting writable version of shared chunk");
208 return &(ptr->memory[0]);
217 CHUNK_WARN(
"getting writable version of shared chunk");
220 return ptr->memory[i];
240 if (initial_len >= bytes)
242 cerr<<
"initialiser too long\n";
248 memcpy(cp->memory, initial, initial_len);
250 cp->memory[initial_len] =
'\0';
257 if (initial_len >= bytes)
259 cerr<<
"initialiser too long\n";
265 memcpy(cp->memory, initial.ptr->memory + initial_start, initial_len);
267 cp->memory[initial_len] =
'\0';
282 if (cp.ptr && cp.ptr->count > 1)
286 memcpy(newchunk->memory, cp.ptr->memory, inuse);
294 if (cp.ptr && cp.ptr->count > 1)
298 memcpy(newchunk->memory, cp.ptr->memory, cp.ptr->size);
313 if (!cp.ptr || cp.ptr->size < newsize)
318 memcpy(newchunk->memory, cp.ptr->memory, cp.ptr->size);
326 if (!cp.ptr || cp.ptr->size < newsize)
331 memcpy(newchunk->memory, cp.ptr->memory, inuse);
342 memcpy(buff, ch.memory, ch.size);
347 memcpy(buff, ch.memory, 20);
351 return (s<<
"[" << ch.size <<
"!" << ch.count <<
"!" << buff <<
"]");
#define walloc(TYPE, SIZE)
void grow_chunk(EST_ChunkPtr &cp, EST_Chunk::EST_chunk_size newsize)
ostream & operator<<(ostream &s, const EST_Chunk &ch)
char & operator()(size_t i) CII(
EST_ChunkPtr & operator=(EST_ChunkPtr cp) CII(
void cp_make_updatable(EST_ChunkPtr &cp, EST_Chunk::EST_chunk_size inuse)
EST_ChunkPtr chunk_allocate(size_t bytes)