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

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

Issue 1720043003: Remove foo != NULL outside of xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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
« no previous file with comments | « core/src/fpdfdoc/doc_tagged.cpp ('k') | core/src/fxcodec/codec/fx_codec_gif.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 "core/include/fxcodec/fx_codec.h" 7 #include "core/include/fxcodec/fx_codec.h"
8 #include "core/include/fxge/fx_dib.h" 8 #include "core/include/fxge/fx_dib.h"
9 #include "core/src/fxcodec/codec/codec_int.h" 9 #include "core/src/fxcodec/codec/codec_int.h"
10 #include "core/src/fxcodec/lbmp/fx_bmp.h" 10 #include "core/src/fxcodec/lbmp/fx_bmp.h"
11 struct FXBMP_Context { 11 struct FXBMP_Context {
12 bmp_decompress_struct_p bmp_ptr; 12 bmp_decompress_struct_p bmp_ptr;
13 void* parent_ptr; 13 void* parent_ptr;
14 void* child_ptr; 14 void* child_ptr;
15 15
16 void* (*m_AllocFunc)(unsigned int); 16 void* (*m_AllocFunc)(unsigned int);
17 void (*m_FreeFunc)(void*); 17 void (*m_FreeFunc)(void*);
18 }; 18 };
19 extern "C" { 19 extern "C" {
20 static void* _bmp_alloc_func(unsigned int size) { 20 static void* _bmp_alloc_func(unsigned int size) {
21 return FX_Alloc(char, size); 21 return FX_Alloc(char, size);
22 } 22 }
23 static void _bmp_free_func(void* p) { 23 static void _bmp_free_func(void* p) {
24 if (p != NULL) { 24 FX_Free(p);
25 FX_Free(p);
26 }
27 } 25 }
28 }; 26 };
29 static void _bmp_error_data(bmp_decompress_struct_p bmp_ptr, 27 static void _bmp_error_data(bmp_decompress_struct_p bmp_ptr,
30 const FX_CHAR* err_msg) { 28 const FX_CHAR* err_msg) {
31 FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1); 29 FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1);
32 longjmp(bmp_ptr->jmpbuf, 1); 30 longjmp(bmp_ptr->jmpbuf, 1);
33 } 31 }
34 static void _bmp_read_scanline(bmp_decompress_struct_p bmp_ptr, 32 static void _bmp_read_scanline(bmp_decompress_struct_p bmp_ptr,
35 int32_t row_num, 33 int32_t row_num,
36 uint8_t* row_buf) { 34 uint8_t* row_buf) {
(...skipping 28 matching lines...) Expand all
65 } 63 }
66 p->bmp_ptr->context_ptr = (void*)p; 64 p->bmp_ptr->context_ptr = (void*)p;
67 p->bmp_ptr->err_ptr = m_szLastError; 65 p->bmp_ptr->err_ptr = m_szLastError;
68 p->bmp_ptr->_bmp_error_fn = _bmp_error_data; 66 p->bmp_ptr->_bmp_error_fn = _bmp_error_data;
69 p->bmp_ptr->_bmp_get_row_fn = _bmp_read_scanline; 67 p->bmp_ptr->_bmp_get_row_fn = _bmp_read_scanline;
70 p->bmp_ptr->_bmp_get_data_position_fn = _bmp_get_data_position; 68 p->bmp_ptr->_bmp_get_data_position_fn = _bmp_get_data_position;
71 return p; 69 return p;
72 } 70 }
73 void CCodec_BmpModule::Finish(void* pContext) { 71 void CCodec_BmpModule::Finish(void* pContext) {
74 FXBMP_Context* p = (FXBMP_Context*)pContext; 72 FXBMP_Context* p = (FXBMP_Context*)pContext;
75 if (p != NULL) { 73 if (p) {
76 _bmp_destroy_decompress(&p->bmp_ptr); 74 _bmp_destroy_decompress(&p->bmp_ptr);
77 p->m_FreeFunc(p); 75 p->m_FreeFunc(p);
78 } 76 }
79 } 77 }
80 int32_t CCodec_BmpModule::ReadHeader(void* pContext, 78 int32_t CCodec_BmpModule::ReadHeader(void* pContext,
81 int32_t* width, 79 int32_t* width,
82 int32_t* height, 80 int32_t* height,
83 FX_BOOL* tb_flag, 81 FX_BOOL* tb_flag,
84 int32_t* components, 82 int32_t* components,
85 int32_t* pal_num, 83 int32_t* pal_num,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 uint8_t** avial_buf_ptr) { 116 uint8_t** avial_buf_ptr) {
119 FXBMP_Context* p = (FXBMP_Context*)pContext; 117 FXBMP_Context* p = (FXBMP_Context*)pContext;
120 return _bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr); 118 return _bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr);
121 } 119 }
122 void CCodec_BmpModule::Input(void* pContext, 120 void CCodec_BmpModule::Input(void* pContext,
123 const uint8_t* src_buf, 121 const uint8_t* src_buf,
124 FX_DWORD src_size) { 122 FX_DWORD src_size) {
125 FXBMP_Context* p = (FXBMP_Context*)pContext; 123 FXBMP_Context* p = (FXBMP_Context*)pContext;
126 _bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size); 124 _bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size);
127 } 125 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_tagged.cpp ('k') | core/src/fxcodec/codec/fx_codec_gif.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698