git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52227 954022d7-b5bf-4e40-9824-e11837661b57

This commit is contained in:
Sergey.Kirillov
2013-11-19 15:47:04 +00:00
committed by Alexander Trofimov
parent 755fd2137c
commit 895589010b
237 changed files with 18 additions and 18 deletions

View File

@ -0,0 +1,62 @@
#include "stdafx.h"
#include <stdlib.h>
#include <stddef.h>
#include "MemoryUtils.h"
#include "Object.h"
#include "Array.h"
//------------------------------------------------------------------------
// Array
//------------------------------------------------------------------------
Array::Array(XRef *pXRef)
{
m_pXRef = pXRef;
m_arrItems = NULL;
m_nItemSize = m_nCount = 0;
m_nRef = 1;
}
Array::~Array()
{
for ( int nIndex = 0; nIndex < m_nCount; ++nIndex)
m_arrItems[nIndex].Free();
MemUtilsFree(m_arrItems);
}
void Array::Add(Object *pItem)
{
if ( m_nCount == m_nItemSize )
{
if ( m_nCount == 0 )
{
m_nItemSize = 8;
}
else
{
m_nItemSize *= 2;
}
m_arrItems = (Object *)MemUtilsReallocArray( m_arrItems, m_nItemSize, sizeof(Object));
}
m_arrItems[m_nCount] = *pItem;
++m_nCount;
}
Object *Array::Get(int nIndex, Object *pObject)
{
if ( nIndex < 0 || nIndex >= m_nCount )
{
return pObject->InitNull();
}
return m_arrItems[nIndex].Fetch( m_pXRef, pObject);
}
Object *Array::GetCopy(int nIndex, Object *pObject)
{
if ( nIndex < 0 || nIndex >= m_nCount )
{
return pObject->InitNull();
}
return m_arrItems[nIndex].Copy(pObject);
}