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