2 * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "CPointerArray.h"
19 #include "TADC_ErrorCode.h"
21 //////////////////////////////////////////////////////////////////////
22 // Construction/Destruction
23 //////////////////////////////////////////////////////////////////////
24 #define BUFFER_INC_SIZE 128
26 CPointerArray::CPointerArray()
33 CPointerArray::~CPointerArray()
35 if( m_ppData != NULL )
41 int CPointerArray::Add( LPVOID pData )
47 if( m_ppData == NULL )
49 m_nMaxSize = BUFFER_INC_SIZE;
50 m_ppData = new LPVOID[ BUFFER_INC_SIZE ];
60 if( m_nNumOfData >= m_nMaxSize )
62 nNewSize = m_nMaxSize += BUFFER_INC_SIZE;
63 ppTemp = new LPVOID[ nNewSize ];
64 IF_TRUE_GOTO( ppTemp == NULL, -1 );
66 memcpy( ppTemp, m_ppData, BUFFER_INC_SIZE * sizeof( LPVOID ) );
70 m_nMaxSize += BUFFER_INC_SIZE;
74 m_ppData[ m_nNumOfData ] = pData;
83 DRM_TAPPS_EXCEPTION("CPointerArray::Add() Error! \n");
89 int CPointerArray::Remove( int nIndex )
94 if( ( nIndex < 0 ) || ( nIndex >= m_nNumOfData ) )
96 nResult = -1;//ERRORMSG( ERROR_INVALID_PARAMETER, NULL );
101 for( i = nIndex ; i < m_nNumOfData - 1 ; i++ )
103 m_ppData[ i ] = m_ppData[ i + 1 ];
114 DRM_TAPPS_EXCEPTION("CPointerArray::Remove() Error! \n");
120 LPVOID CPointerArray::Get( int nIndex )
122 if( ( nIndex < 0 ) || ( nIndex >= m_nNumOfData ) )
127 return m_ppData[ nIndex ];