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 2007 ZXing authors | 8 * Copyright 2007 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 14 matching lines...) Expand all Loading... |
25 #include "xfa/src/fxbarcode/utils.h" | 25 #include "xfa/src/fxbarcode/utils.h" |
26 | 26 |
27 CBC_QRCoderBitVector::CBC_QRCoderBitVector() { | 27 CBC_QRCoderBitVector::CBC_QRCoderBitVector() { |
28 m_sizeInBits = 0; | 28 m_sizeInBits = 0; |
29 m_size = 32; | 29 m_size = 32; |
30 } | 30 } |
31 void CBC_QRCoderBitVector::Init() { | 31 void CBC_QRCoderBitVector::Init() { |
32 m_array = FX_Alloc(uint8_t, m_size); | 32 m_array = FX_Alloc(uint8_t, m_size); |
33 } | 33 } |
34 CBC_QRCoderBitVector::~CBC_QRCoderBitVector() { | 34 CBC_QRCoderBitVector::~CBC_QRCoderBitVector() { |
35 if (m_array != NULL) { | 35 FX_Free(m_array); |
36 FX_Free(m_array); | |
37 } | |
38 m_size = 0; | |
39 m_sizeInBits = 0; | |
40 } | 36 } |
41 void CBC_QRCoderBitVector::Clear() { | 37 void CBC_QRCoderBitVector::Clear() { |
42 if (m_array != NULL) { | 38 FX_Free(m_array); |
43 FX_Free(m_array); | |
44 m_array = NULL; | |
45 } | |
46 m_sizeInBits = 0; | 39 m_sizeInBits = 0; |
47 m_size = 32; | 40 m_size = 32; |
48 m_array = FX_Alloc(uint8_t, m_size); | 41 m_array = FX_Alloc(uint8_t, m_size); |
49 } | 42 } |
50 int32_t CBC_QRCoderBitVector::At(int32_t index, int32_t& e) { | 43 int32_t CBC_QRCoderBitVector::At(int32_t index, int32_t& e) { |
51 if (index < 0 || index >= m_sizeInBits) { | 44 if (index < 0 || index >= m_sizeInBits) { |
52 e = BCExceptionBadIndexException; | 45 e = BCExceptionBadIndexException; |
53 BC_EXCEPTION_CHECK_ReturnValue(e, 0); | 46 BC_EXCEPTION_CHECK_ReturnValue(e, 0); |
54 } | 47 } |
55 int32_t value = m_array[index >> 3] & 0xff; | 48 int32_t value = m_array[index >> 3] & 0xff; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 m_array[i] ^= (other->GetArray())[i]; | 108 m_array[i] ^= (other->GetArray())[i]; |
116 } | 109 } |
117 } | 110 } |
118 uint8_t* CBC_QRCoderBitVector::GetArray() { | 111 uint8_t* CBC_QRCoderBitVector::GetArray() { |
119 return m_array; | 112 return m_array; |
120 } | 113 } |
121 void CBC_QRCoderBitVector::AppendByte(int32_t value) { | 114 void CBC_QRCoderBitVector::AppendByte(int32_t value) { |
122 if ((m_sizeInBits >> 3) == m_size) { | 115 if ((m_sizeInBits >> 3) == m_size) { |
123 uint8_t* newArray = FX_Alloc(uint8_t, m_size << 1); | 116 uint8_t* newArray = FX_Alloc(uint8_t, m_size << 1); |
124 FXSYS_memcpy(newArray, m_array, m_size); | 117 FXSYS_memcpy(newArray, m_array, m_size); |
125 if (m_array != NULL) { | 118 FX_Free(m_array); |
126 FX_Free(m_array); | |
127 } | |
128 m_array = newArray; | 119 m_array = newArray; |
129 m_size = m_size << 1; | 120 m_size = m_size << 1; |
130 } | 121 } |
131 m_array[m_sizeInBits >> 3] = (uint8_t)value; | 122 m_array[m_sizeInBits >> 3] = (uint8_t)value; |
132 m_sizeInBits += 8; | 123 m_sizeInBits += 8; |
133 } | 124 } |
OLD | NEW |