Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp

Issue 1726373002: Remove foo != NULL checks in xfa/src/fxbarcode. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 } 39 }
40 void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) { 40 void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
41 m_width = width; 41 m_width = width;
42 m_height = height; 42 m_height = height;
43 int32_t rowSize = (width + 31) >> 5; 43 int32_t rowSize = (width + 31) >> 5;
44 m_rowSize = rowSize; 44 m_rowSize = rowSize;
45 m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); 45 m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height);
46 FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); 46 FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
47 } 47 }
48 CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { 48 CBC_CommonBitMatrix::~CBC_CommonBitMatrix() {
49 if (m_bits != NULL) { 49 FX_Free(m_bits);
50 FX_Free(m_bits);
51 }
52 m_bits = NULL;
53 m_height = m_width = m_rowSize = 0;
54 } 50 }
55 FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { 51 FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) {
56 int32_t offset = y * m_rowSize + (x >> 5); 52 int32_t offset = y * m_rowSize + (x >> 5);
57 if (offset >= m_rowSize * m_height || offset < 0) { 53 if (offset >= m_rowSize * m_height || offset < 0) {
58 return false; 54 return false;
59 } 55 }
60 return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; 56 return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0;
61 } 57 }
62 int32_t* CBC_CommonBitMatrix::GetBits() { 58 int32_t* CBC_CommonBitMatrix::GetBits() {
63 return m_bits; 59 return m_bits;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 int32_t CBC_CommonBitMatrix::GetRowSize() { 136 int32_t CBC_CommonBitMatrix::GetRowSize() {
141 return m_rowSize; 137 return m_rowSize;
142 } 138 }
143 int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { 139 int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) {
144 if (m_width != m_height) { 140 if (m_width != m_height) {
145 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; 141 e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix;
146 return 0; 142 return 0;
147 } 143 }
148 return m_width; 144 return m_width;
149 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698