19 #include "ObjectMap.hpp"
21 NdbObjectIdMap::NdbObjectIdMap(Uint32 sz, Uint32 eSz):
24 m_firstFree(InvalidId),
25 m_lastFree(InvalidId),
29 #ifdef DEBUG_OBJECTMAP
30 ndbout_c(
"NdbObjectIdMap:::NdbObjectIdMap(%u)", sz);
34 NdbObjectIdMap::~NdbObjectIdMap()
36 assert(checkConsistency());
41 int NdbObjectIdMap::expand(Uint32 incSize)
43 assert(checkConsistency());
44 Uint32 newSize = m_size + incSize;
45 MapEntry * tmp = (MapEntry*)realloc(m_map, newSize *
sizeof(MapEntry));
51 for(Uint32
i = m_size;
i < newSize-1;
i++)
53 m_map[
i].setNext(
i+1);
56 m_lastFree = newSize - 1;
57 m_map[newSize-1].setNext(InvalidId);
59 assert(checkConsistency());
63 g_eventLogger->
error(
"NdbObjectIdMap::expand: realloc(%u*%lu) failed",
64 newSize,
sizeof(MapEntry));
70 bool NdbObjectIdMap::checkConsistency()
72 if (m_firstFree == InvalidId)
74 for (Uint32
i = 0;
i<m_size;
i++)
76 if (m_map[
i].isFree())
85 Uint32
i = m_firstFree;
86 while (m_map[i].getNext() != InvalidId)
88 i = m_map[
i].getNext();
90 assert(i == m_lastFree);
91 return i == m_lastFree;