utility functions
| 229 | |
| 230 | // utility functions |
| 231 | void* 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 | |
| 262 | template<typename I> void |
| 263 | index_cleanup(I* index |