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()
39 int CPointerArray::Add(LPVOID pData)
45 if (m_ppData == NULL) {
46 m_nMaxSize = BUFFER_INC_SIZE;
47 m_ppData = new LPVOID[BUFFER_INC_SIZE];
49 if (m_ppData == NULL) {
55 if (m_nNumOfData >= m_nMaxSize) {
56 nNewSize = m_nMaxSize += BUFFER_INC_SIZE;
57 ppTemp = new LPVOID[nNewSize];
58 IF_TRUE_GOTO(ppTemp == NULL, -1);
60 memcpy(ppTemp, m_ppData, BUFFER_INC_SIZE * sizeof(LPVOID));
64 m_nMaxSize += BUFFER_INC_SIZE;
68 m_ppData[m_nNumOfData] = pData;
76 DRM_TAPPS_EXCEPTION("CPointerArray::Add() Error! \n");
81 int CPointerArray::Remove(int nIndex)
85 if ((nIndex < 0) || (nIndex >= m_nNumOfData)) {
86 nResult = -1; //ERRORMSG( ERROR_INVALID_PARAMETER, NULL );
90 for (int i = nIndex; i < m_nNumOfData - 1; i++)
91 m_ppData[i] = m_ppData[i + 1];
100 DRM_TAPPS_EXCEPTION("CPointerArray::Remove() Error! \n");
105 LPVOID CPointerArray::Get(int nIndex)
107 if ((nIndex < 0) || (nIndex >= m_nNumOfData))
110 return m_ppData[nIndex];