MCPcopy Create free account
hub / github.com/buggins/coolreader / alloc

Method alloc

crengine/src/lvstring.cpp:133–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133lstring_chunk_t * lstring_chunk_t::alloc()
134{
135 if (!slices_initialized)
136 init_ls_storage();
137 // search for existing slice
138 for (int i=slices_count-1; i>=0; --i)
139 {
140 if (slices[i]->pFree != NULL)
141 return slices[i]->alloc_chunk();
142 }
143 // alloc new slice
144 if (slices_count >= MAX_SLICE_COUNT)
145 crFatalError();
146 lstring_chunk_slice_t * new_slice = new lstring_chunk_slice_t( FIRST_SLICE_SIZE << (slices_count+1) );
147 slices[slices_count++] = new_slice;
148 return slices[slices_count-1]->alloc_chunk();
149}
150
151void lstring_chunk_t::free( lstring_chunk_t * pChunk )
152{

Callers 1

ldomAllocFunction · 0.45

Calls 3

init_ls_storageFunction · 0.85
alloc_chunkMethod · 0.80
crFatalErrorFunction · 0.70

Tested by

no test coverage detected