MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / createIndex

Function createIndex

dds/InfoRepo/PersistenceUpdater.cpp:231–260  ·  view source on GitHub ↗

utility functions

Source from the content-addressed store, hash-verified

229
230// utility functions
231void* createIndex(const std::string& tag
232 , PersistenceUpdater::ALLOCATOR& allocator
233 , size_t size, bool& exists)
234{
235 void* index = 0;
236
237 // This is the easy case since if we find hash table in the
238 // memory-mapped file we know it's already initialized.
239 if (allocator.find(tag.c_str(), index) == 0) {
240 exists = true;
241 return index;
242
243 } else {
244 ACE_ALLOCATOR_RETURN(index, allocator.malloc(size), 0);
245
246 if (allocator.bind(tag.c_str(), index) == -1) {
247 allocator.free(index);
248 index = 0;
249 }
250 }
251
252 if (!index) {
253 ACE_ERROR((LM_ERROR,
254 ACE_TEXT("(%P|%t) ERROR: PersistenceUpdater::init: ")
255 ACE_TEXT("Initial allocation/Bind failed for %C.\n"),
256 tag.c_str()));
257 }
258
259 return index;
260}
261
262template<typename I> void
263index_cleanup(I* index

Callers 1

initMethod · 0.85

Calls 4

findMethod · 0.45
mallocMethod · 0.45
bindMethod · 0.45
freeMethod · 0.45

Tested by

no test coverage detected