| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
| 7 /* | 7 /* |
| 8 * Copyright 2008 ZXing authors | 8 * Copyright 2008 ZXing authors |
| 9 * | 9 * |
| 10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "../barcode.h" | 23 #include "../barcode.h" |
| 24 #include "BC_CommonByteArray.h" | 24 #include "BC_CommonByteArray.h" |
| 25 CBC_CommonByteArray::CBC_CommonByteArray() | 25 CBC_CommonByteArray::CBC_CommonByteArray() |
| 26 { | 26 { |
| 27 m_bytes = NULL; | 27 m_bytes = NULL; |
| 28 m_size = 0; | 28 m_size = 0; |
| 29 m_index = 0; | 29 m_index = 0; |
| 30 } | 30 } |
| 31 CBC_CommonByteArray::CBC_CommonByteArray(FX_INT32 size) | 31 CBC_CommonByteArray::CBC_CommonByteArray(int32_t size) |
| 32 { | 32 { |
| 33 m_size = size; | 33 m_size = size; |
| 34 m_bytes = FX_Alloc(FX_BYTE, size); | 34 m_bytes = FX_Alloc(uint8_t, size); |
| 35 FXSYS_memset32(m_bytes, 0, size); | 35 FXSYS_memset32(m_bytes, 0, size); |
| 36 m_index = 0; | 36 m_index = 0; |
| 37 } | 37 } |
| 38 CBC_CommonByteArray::CBC_CommonByteArray(FX_BYTE* byteArray, FX_INT32 size) | 38 CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) |
| 39 { | 39 { |
| 40 m_size = size; | 40 m_size = size; |
| 41 m_bytes = FX_Alloc(FX_BYTE, size); | 41 m_bytes = FX_Alloc(uint8_t, size); |
| 42 FXSYS_memcpy32(m_bytes, byteArray, size); | 42 FXSYS_memcpy32(m_bytes, byteArray, size); |
| 43 m_index = size; | 43 m_index = size; |
| 44 } | 44 } |
| 45 CBC_CommonByteArray::~CBC_CommonByteArray() | 45 CBC_CommonByteArray::~CBC_CommonByteArray() |
| 46 { | 46 { |
| 47 if ( m_bytes != NULL) { | 47 if ( m_bytes != NULL) { |
| 48 FX_Free( m_bytes ); | 48 FX_Free( m_bytes ); |
| 49 m_bytes = NULL; | 49 m_bytes = NULL; |
| 50 } | 50 } |
| 51 m_index = 0; | 51 m_index = 0; |
| 52 m_size = 0; | 52 m_size = 0; |
| 53 } | 53 } |
| 54 FX_INT32 CBC_CommonByteArray::At(FX_INT32 index) | 54 int32_t CBC_CommonByteArray::At(int32_t index) |
| 55 { | 55 { |
| 56 return m_bytes[index] & 0xff; | 56 return m_bytes[index] & 0xff; |
| 57 } | 57 } |
| 58 void CBC_CommonByteArray::Set(FX_INT32 index, FX_INT32 value) | 58 void CBC_CommonByteArray::Set(int32_t index, int32_t value) |
| 59 { | 59 { |
| 60 m_bytes[index] = (FX_BYTE) value; | 60 m_bytes[index] = (uint8_t) value; |
| 61 } | 61 } |
| 62 FX_INT32 CBC_CommonByteArray::Size() | 62 int32_t CBC_CommonByteArray::Size() |
| 63 { | 63 { |
| 64 return m_size; | 64 return m_size; |
| 65 } | 65 } |
| 66 FX_BOOL CBC_CommonByteArray::IsEmpty() | 66 FX_BOOL CBC_CommonByteArray::IsEmpty() |
| 67 { | 67 { |
| 68 return m_size == 0; | 68 return m_size == 0; |
| 69 } | 69 } |
| 70 void CBC_CommonByteArray::AppendByte(FX_INT32 value) | 70 void CBC_CommonByteArray::AppendByte(int32_t value) |
| 71 { | 71 { |
| 72 if (m_size == 0 || m_index >= m_size) { | 72 if (m_size == 0 || m_index >= m_size) { |
| 73 FX_INT32 newSize = FX_MAX(32, m_size << 1); | 73 int32_t newSize = FX_MAX(32, m_size << 1); |
| 74 Reserve(newSize); | 74 Reserve(newSize); |
| 75 } | 75 } |
| 76 m_bytes[m_index] = (FX_BYTE)value; | 76 m_bytes[m_index] = (uint8_t)value; |
| 77 m_index++; | 77 m_index++; |
| 78 } | 78 } |
| 79 void CBC_CommonByteArray::Reserve(FX_INT32 capacity) | 79 void CBC_CommonByteArray::Reserve(int32_t capacity) |
| 80 { | 80 { |
| 81 if (m_bytes == NULL || m_size < capacity) { | 81 if (m_bytes == NULL || m_size < capacity) { |
| 82 FX_BYTE *newArray = FX_Alloc(FX_BYTE, capacity); | 82 uint8_t *newArray = FX_Alloc(uint8_t, capacity); |
| 83 FXSYS_memset32(newArray, 0, capacity); | 83 FXSYS_memset32(newArray, 0, capacity); |
| 84 if (m_bytes != NULL) { | 84 if (m_bytes != NULL) { |
| 85 FXSYS_memcpy32(newArray, m_bytes, m_size); | 85 FXSYS_memcpy32(newArray, m_bytes, m_size); |
| 86 FX_Free( m_bytes ); | 86 FX_Free( m_bytes ); |
| 87 } | 87 } |
| 88 m_bytes = newArray; | 88 m_bytes = newArray; |
| 89 m_size = capacity; | 89 m_size = capacity; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 void CBC_CommonByteArray::Set(FX_BYTE* source, FX_INT32 offset, FX_INT32 count) | 92 void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) |
| 93 { | 93 { |
| 94 if (m_bytes != NULL) { | 94 if (m_bytes != NULL) { |
| 95 FX_Free( m_bytes ); | 95 FX_Free( m_bytes ); |
| 96 } | 96 } |
| 97 m_bytes = FX_Alloc(FX_BYTE, count); | 97 m_bytes = FX_Alloc(uint8_t, count); |
| 98 m_size = count; | 98 m_size = count; |
| 99 FXSYS_memcpy32(m_bytes, source + offset, count); | 99 FXSYS_memcpy32(m_bytes, source + offset, count); |
| 100 m_index = count; | 100 m_index = count; |
| 101 } | 101 } |
| 102 void CBC_CommonByteArray::Set(CFX_ByteArray* source, FX_INT32 offset, FX_INT32 c
ount) | 102 void CBC_CommonByteArray::Set(CFX_ByteArray* source, int32_t offset, int32_t cou
nt) |
| 103 { | 103 { |
| 104 if (m_bytes != NULL) { | 104 if (m_bytes != NULL) { |
| 105 FX_Free( m_bytes ); | 105 FX_Free( m_bytes ); |
| 106 } | 106 } |
| 107 m_bytes = FX_Alloc(FX_BYTE, count); | 107 m_bytes = FX_Alloc(uint8_t, count); |
| 108 m_size = count; | 108 m_size = count; |
| 109 FX_INT32 i; | 109 int32_t i; |
| 110 for(i = 0; i < count; i++) { | 110 for(i = 0; i < count; i++) { |
| 111 m_bytes[i] = source->operator [](i + offset); | 111 m_bytes[i] = source->operator [](i + offset); |
| 112 } | 112 } |
| 113 m_index = m_size; | 113 m_index = m_size; |
| 114 } | 114 } |
| OLD | NEW |