1 // Copyright 2014 PDFium Authors. All rights reserved.
\r
2 // Use of this source code is governed by a BSD-style license that can be
\r
3 // found in the LICENSE file.
\r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
\r
8 #include "include/BC_CommonByteArray.h"
\r
9 CBC_CommonByteArray::CBC_CommonByteArray()
\r
15 CBC_CommonByteArray::CBC_CommonByteArray(FX_INT32 size)
\r
18 m_bytes = FX_Alloc(FX_BYTE, size);
\r
19 FXSYS_memset32(m_bytes, 0, size);
\r
22 CBC_CommonByteArray::CBC_CommonByteArray(FX_BYTE* byteArray, FX_INT32 size)
\r
25 m_bytes = FX_Alloc(FX_BYTE, size);
\r
26 FXSYS_memcpy32(m_bytes, byteArray, size);
\r
29 CBC_CommonByteArray::~CBC_CommonByteArray()
\r
31 if ( m_bytes != NULL) {
\r
38 FX_INT32 CBC_CommonByteArray::At(FX_INT32 index)
\r
40 return m_bytes[index] & 0xff;
\r
42 void CBC_CommonByteArray::Set(FX_INT32 index, FX_INT32 value)
\r
44 m_bytes[index] = (FX_BYTE) value;
\r
46 FX_INT32 CBC_CommonByteArray::Size()
\r
50 FX_BOOL CBC_CommonByteArray::IsEmpty()
\r
54 void CBC_CommonByteArray::AppendByte(FX_INT32 value)
\r
56 if (m_size == 0 || m_index >= m_size) {
\r
57 FX_INT32 newSize = FX_MAX(32, m_size << 1);
\r
60 m_bytes[m_index] = (FX_BYTE)value;
\r
63 void CBC_CommonByteArray::Reserve(FX_INT32 capacity)
\r
65 if (m_bytes == NULL || m_size < capacity) {
\r
66 FX_BYTE *newArray = FX_Alloc(FX_BYTE, capacity);
\r
67 FXSYS_memset32(newArray, 0, capacity);
\r
68 if (m_bytes != NULL) {
\r
69 FXSYS_memcpy32(newArray, m_bytes, m_size);
\r
76 void CBC_CommonByteArray::Set(FX_BYTE* source, FX_INT32 offset, FX_INT32 count)
\r
78 if (m_bytes != NULL) {
\r
81 m_bytes = FX_Alloc(FX_BYTE, count);
\r
83 FXSYS_memcpy32(m_bytes, source + offset, count);
\r
86 void CBC_CommonByteArray::Set(CFX_ByteArray* source, FX_INT32 offset, FX_INT32 count)
\r
88 if (m_bytes != NULL) {
\r
91 m_bytes = FX_Alloc(FX_BYTE, count);
\r
94 for(i = 0; i < count; i++) {
\r
95 m_bytes[i] = source->operator [](i + offset);
\r