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

Side by Side Diff: core/src/fxcodec/codec/fx_codec_flate.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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
« no previous file with comments | « core/src/fxcodec/codec/fx_codec.cpp ('k') | core/src/fxcodec/codec/fx_codec_icc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 #include "codec_int.h" 7 #include "codec_int.h"
8 #include "core/include/fxcodec/fx_codec.h" 8 #include "core/include/fxcodec/fx_codec.h"
9 #include "core/include/fxcodec/fx_codec_flate.h" 9 #include "core/include/fxcodec/fx_codec_flate.h"
10 #include "third_party/base/nonstd_unique_ptr.h" 10 #include "third_party/base/nonstd_unique_ptr.h"
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 static void FPDFAPI_FlateCompress(unsigned char* dest_buf, 28 static void FPDFAPI_FlateCompress(unsigned char* dest_buf,
29 unsigned long* dest_size, 29 unsigned long* dest_size,
30 const unsigned char* src_buf, 30 const unsigned char* src_buf,
31 unsigned long src_size) { 31 unsigned long src_size) {
32 compress(dest_buf, dest_size, src_buf, src_size); 32 compress(dest_buf, dest_size, src_buf, src_size);
33 } 33 }
34 void* FPDFAPI_FlateInit(void* (*alloc_func)(void*, unsigned int, unsigned int), 34 void* FPDFAPI_FlateInit(void* (*alloc_func)(void*, unsigned int, unsigned int),
35 void (*free_func)(void*, void*)) { 35 void (*free_func)(void*, void*)) {
36 z_stream* p = (z_stream*)alloc_func(0, 1, sizeof(z_stream)); 36 z_stream* p = (z_stream*)alloc_func(0, 1, sizeof(z_stream));
37 if (p == NULL) { 37 if (!p) {
38 return NULL; 38 return NULL;
39 } 39 }
40 FXSYS_memset(p, 0, sizeof(z_stream)); 40 FXSYS_memset(p, 0, sizeof(z_stream));
41 p->zalloc = alloc_func; 41 p->zalloc = alloc_func;
42 p->zfree = free_func; 42 p->zfree = free_func;
43 inflateInit(p); 43 inflateInit(p);
44 return p; 44 return p;
45 } 45 }
46 void FPDFAPI_FlateInput(void* context, 46 void FPDFAPI_FlateInput(void* context,
47 const unsigned char* src_buf, 47 const unsigned char* src_buf,
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 m_pPredictRaw = FX_Alloc(uint8_t, m_PredictPitch + 1); 828 m_pPredictRaw = FX_Alloc(uint8_t, m_PredictPitch + 1);
829 m_pPredictBuffer = FX_Alloc(uint8_t, m_PredictPitch); 829 m_pPredictBuffer = FX_Alloc(uint8_t, m_PredictPitch);
830 } 830 }
831 } 831 }
832 } 832 }
833 FX_BOOL CCodec_FlateScanlineDecoder::v_Rewind() { 833 FX_BOOL CCodec_FlateScanlineDecoder::v_Rewind() {
834 if (m_pFlate) { 834 if (m_pFlate) {
835 FPDFAPI_FlateEnd(m_pFlate); 835 FPDFAPI_FlateEnd(m_pFlate);
836 } 836 }
837 m_pFlate = FPDFAPI_FlateInit(my_alloc_func, my_free_func); 837 m_pFlate = FPDFAPI_FlateInit(my_alloc_func, my_free_func);
838 if (m_pFlate == NULL) { 838 if (!m_pFlate) {
839 return FALSE; 839 return FALSE;
840 } 840 }
841 FPDFAPI_FlateInput(m_pFlate, m_SrcBuf, m_SrcSize); 841 FPDFAPI_FlateInput(m_pFlate, m_SrcBuf, m_SrcSize);
842 m_LeftOver = 0; 842 m_LeftOver = 0;
843 return TRUE; 843 return TRUE;
844 } 844 }
845 uint8_t* CCodec_FlateScanlineDecoder::v_GetNextLine() { 845 uint8_t* CCodec_FlateScanlineDecoder::v_GetNextLine() {
846 if (m_Predictor) { 846 if (m_Predictor) {
847 if (m_Pitch == m_PredictPitch) { 847 if (m_Pitch == m_PredictPitch) {
848 if (m_Predictor == 2) { 848 if (m_Predictor == 2) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 FX_DWORD src_size, 994 FX_DWORD src_size,
995 uint8_t*& dest_buf, 995 uint8_t*& dest_buf,
996 FX_DWORD& dest_size) { 996 FX_DWORD& dest_size) {
997 dest_size = src_size + src_size / 1000 + 12; 997 dest_size = src_size + src_size / 1000 + 12;
998 dest_buf = FX_Alloc(uint8_t, dest_size); 998 dest_buf = FX_Alloc(uint8_t, dest_size);
999 unsigned long temp_size = dest_size; 999 unsigned long temp_size = dest_size;
1000 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); 1000 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size);
1001 dest_size = (FX_DWORD)temp_size; 1001 dest_size = (FX_DWORD)temp_size;
1002 return TRUE; 1002 return TRUE;
1003 } 1003 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec.cpp ('k') | core/src/fxcodec/codec/fx_codec_icc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698