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

Side by Side Diff: core/src/fpdfapi/fpdf_font/fpdf_font_utility.cpp

Issue 429593005: Fix a few more warnings in chromium_code mode. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_font/ttgsubtable.h » ('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 "../../../include/fpdfapi/fpdf_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_resource.h" 8 #include "../../../include/fpdfapi/fpdf_resource.h"
9 #include "../../../include/fxcodec/fx_codec.h" 9 #include "../../../include/fxcodec/fx_codec.h"
10 #include "font_int.h" 10 #include "font_int.h"
11 #ifndef _FPDFAPI_MINI_ 11 #ifndef _FPDFAPI_MINI_
12 typedef struct { 12 typedef struct {
13 FXSYS_FILE* m_pFile; 13 FXSYS_FILE* m_pFile;
14 int m_nFiles; 14 int m_nFiles;
15 int m_IndexSize; 15 int m_IndexSize;
16 int m_IndexOffset; 16 int m_IndexOffset;
17 } FXFC_PACKAGE; 17 } FXFC_PACKAGE;
18 FX_LPVOID FXFC_LoadPackage(FX_LPCSTR name) 18 FX_LPVOID FXFC_LoadPackage(FX_LPCSTR name)
19 { 19 {
20 FXSYS_FILE* file = FXSYS_fopen(name, (FX_LPCSTR)"rb"); 20 FXSYS_FILE* file = FXSYS_fopen(name, (FX_LPCSTR)"rb");
21 if (file == NULL) { 21 if (file == NULL) {
22 return NULL; 22 return NULL;
23 } 23 }
24 FX_BYTE buf[256]; 24 FX_BYTE buf[256];
25 size_t read = FXSYS_fread(buf, 1, 20, file); 25 FXSYS_fread(buf, 1, 20, file);
26 if (*(FX_DWORD*)buf != 0x43465846) { 26 if (*(FX_DWORD*)buf != 0x43465846) {
27 FXSYS_fclose(file); 27 FXSYS_fclose(file);
28 return NULL; 28 return NULL;
29 } 29 }
30 FXFC_PACKAGE* pPackage = FX_Alloc(FXFC_PACKAGE, 1); 30 FXFC_PACKAGE* pPackage = FX_Alloc(FXFC_PACKAGE, 1);
31 pPackage->m_pFile = file; 31 pPackage->m_pFile = file;
32 pPackage->m_nFiles = *(int*)(buf + 8); 32 pPackage->m_nFiles = *(int*)(buf + 8);
33 pPackage->m_IndexSize = *(int*)(buf + 12); 33 pPackage->m_IndexSize = *(int*)(buf + 12);
34 pPackage->m_IndexOffset = *(int*)(buf + 16); 34 pPackage->m_IndexOffset = *(int*)(buf + 16);
35 return pPackage; 35 return pPackage;
36 } 36 }
37 void FXFC_ClosePackage(FX_LPVOID p) 37 void FXFC_ClosePackage(FX_LPVOID p)
38 { 38 {
39 FXFC_PACKAGE* pPackage = (FXFC_PACKAGE*)p; 39 FXFC_PACKAGE* pPackage = (FXFC_PACKAGE*)p;
40 FXSYS_fclose(pPackage->m_pFile); 40 FXSYS_fclose(pPackage->m_pFile);
41 FX_Free(pPackage); 41 FX_Free(pPackage);
42 } 42 }
43 FX_BOOL FXFC_LoadFile(FX_LPVOID p, FX_LPCSTR name, FX_LPBYTE& pBuffer, FX_DWORD& size) 43 FX_BOOL FXFC_LoadFile(FX_LPVOID p, FX_LPCSTR name, FX_LPBYTE& pBuffer, FX_DWORD& size)
44 { 44 {
45 FXFC_PACKAGE* pPackage = (FXFC_PACKAGE*)p; 45 FXFC_PACKAGE* pPackage = (FXFC_PACKAGE*)p;
46 FXSYS_fseek(pPackage->m_pFile, pPackage->m_IndexOffset, FXSYS_SEEK_SET); 46 FXSYS_fseek(pPackage->m_pFile, pPackage->m_IndexOffset, FXSYS_SEEK_SET);
47 FX_BYTE buf[128]; 47 FX_BYTE buf[128];
48 size_t read = 0;
49 for (int i = 0; i < pPackage->m_nFiles; i ++) { 48 for (int i = 0; i < pPackage->m_nFiles; i ++) {
50 read = FXSYS_fread(buf, pPackage->m_IndexSize, 1, pPackage->m_pFile); 49 FXSYS_fread(buf, pPackage->m_IndexSize, 1, pPackage->m_pFile);
51 if (FXSYS_stricmp((FX_LPCSTR)buf, name) == 0) { 50 if (FXSYS_stricmp((FX_LPCSTR)buf, name) == 0) {
52 FX_DWORD offset = *(FX_DWORD*)&buf[64]; 51 FX_DWORD offset = *(FX_DWORD*)&buf[64];
53 size = *(FX_DWORD*)&buf[68]; 52 size = *(FX_DWORD*)&buf[68];
54 pBuffer = FX_Alloc(FX_BYTE, size); 53 pBuffer = FX_Alloc(FX_BYTE, size);
55 FXSYS_fseek(pPackage->m_pFile, offset, FXSYS_SEEK_SET); 54 FXSYS_fseek(pPackage->m_pFile, offset, FXSYS_SEEK_SET);
56 read = FXSYS_fread(pBuffer, size, 1, pPackage->m_pFile); 55 FXSYS_fread(pBuffer, size, 1, pPackage->m_pFile);
57 if (buf[72]) { 56 if (buf[72]) {
58 FX_DWORD orig_size; 57 FX_DWORD orig_size;
59 FX_LPBYTE comp_buf = pBuffer; 58 FX_LPBYTE comp_buf = pBuffer;
60 CPDF_ModuleMgr::Get()->GetFlateModule()->FlateOrLZWDecode(FALSE, comp_buf, size, FALSE, 59 CPDF_ModuleMgr::Get()->GetFlateModule()->FlateOrLZWDecode(FALSE, comp_buf, size, FALSE,
61 0, 0, 0, 0, 0, pBuffer, orig_size); 60 0, 0, 0, 0, 0, pBuffer, orig_size);
62 FX_Free(comp_buf); 61 FX_Free(comp_buf);
63 size = orig_size; 62 size = orig_size;
64 } 63 }
65 return TRUE; 64 return TRUE;
66 } 65 }
(...skipping 21 matching lines...) Expand all
88 { 87 {
89 if (m_pTable == NULL) { 88 if (m_pTable == NULL) {
90 return NULL; 89 return NULL;
91 } 90 }
92 if ((int)index < (int)m_pHeader->dwStartIndex || index > m_pHeader->dwEndInd ex) { 91 if ((int)index < (int)m_pHeader->dwStartIndex || index > m_pHeader->dwEndInd ex) {
93 return NULL; 92 return NULL;
94 } 93 }
95 return m_pTable + (index - m_pHeader->dwStartIndex) * m_pHeader->dwRecordSiz e; 94 return m_pTable + (index - m_pHeader->dwStartIndex) * m_pHeader->dwRecordSiz e;
96 } 95 }
97 #endif 96 #endif
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_font/fpdf_font.cpp ('k') | core/src/fpdfapi/fpdf_font/ttgsubtable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698