Esempio n. 1
0
 void ObjectVectorObject::grow(uint32 newCapacity, bool exact)
 {
     if (newCapacity > m_capacity)
     {
         if(!exact)
             newCapacity = newCapacity + (newCapacity >>2);
         //newCapacity = ((newCapacity+kGrowthIncr)/kGrowthIncr)*kGrowthIncr;
         GC* gc = GC::GetGC(this);
         Atom* newArray = (Atom*) gc->Calloc(newCapacity, sizeof(Atom), GC::kContainsPointers);
         nullAtomRange(newArray, newCapacity);
         Atom* oldAtoms = m_array;
         if (!newArray)
         {
             toplevel()->throwError(kOutOfMemoryError);
         }
         if (m_array)
         {
             VMPI_memcpy(newArray, m_array, m_length * sizeof(Atom));
             nullAtomRange(oldAtoms, m_length);
             gc->Free(oldAtoms);
         }
         m_array = newArray;
         m_capacity = newCapacity;
     }
 }