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

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

Issue 372473003: Remove custom memory manager (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Change malloc to calloc Created 6 years, 5 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 6
7 #include "../../../include/fpdfapi/fpdf_module.h" 7 #include "../../../include/fpdfapi/fpdf_module.h"
8 #include "../../../include/fpdfapi/fpdf_page.h" 8 #include "../../../include/fpdfapi/fpdf_page.h"
9 #include "font_int.h" 9 #include "font_int.h"
10 #include "../fpdf_cmaps/cmap_int.h" 10 #include "../fpdf_cmaps/cmap_int.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 break; 404 break;
405 } 405 }
406 index ++; 406 index ++;
407 } 407 }
408 const CPDF_PredefinedCMap& map = g_PredefinedCMaps[index]; 408 const CPDF_PredefinedCMap& map = g_PredefinedCMaps[index];
409 m_Charset = map.m_Charset; 409 m_Charset = map.m_Charset;
410 m_Coding = map.m_Coding; 410 m_Coding = map.m_Coding;
411 m_CodingScheme = map.m_CodingScheme; 411 m_CodingScheme = map.m_CodingScheme;
412 if (m_CodingScheme == MixedTwoBytes) { 412 if (m_CodingScheme == MixedTwoBytes) {
413 m_pLeadingBytes = FX_Alloc(FX_BYTE, 256); 413 m_pLeadingBytes = FX_Alloc(FX_BYTE, 256);
414 FXSYS_memset32(m_pLeadingBytes, 0, 256);
415 for (FX_DWORD i = 0; i < map.m_LeadingSegCount; i ++) { 414 for (FX_DWORD i = 0; i < map.m_LeadingSegCount; i ++) {
416 for (int b = map.m_LeadingSegs[i * 2]; b <= map.m_LeadingSegs[i * 2 + 1]; b ++) { 415 for (int b = map.m_LeadingSegs[i * 2]; b <= map.m_LeadingSegs[i * 2 + 1]; b ++) {
417 m_pLeadingBytes[b] = 1; 416 m_pLeadingBytes[b] = 1;
418 } 417 }
419 } 418 }
420 } 419 }
421 FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap); 420 FPDFAPI_FindEmbeddedCMap(pName, m_Charset, m_Coding, m_pEmbedMap);
422 if (m_pEmbedMap) { 421 if (m_pEmbedMap) {
423 m_bLoaded = TRUE; 422 m_bLoaded = TRUE;
424 return TRUE; 423 return TRUE;
425 } 424 }
426 #ifndef _FPDFAPI_MINI_ 425 #ifndef _FPDFAPI_MINI_
427 FX_LPVOID pPackage = pMgr->GetPackage(bPromptCJK); 426 FX_LPVOID pPackage = pMgr->GetPackage(bPromptCJK);
428 FX_LPBYTE pBuffer; 427 FX_LPBYTE pBuffer;
429 FX_DWORD size; 428 FX_DWORD size;
430 if (pPackage == NULL || !FXFC_LoadFile(pPackage, m_PredefinedCMap, pBuffer, size)) { 429 if (pPackage == NULL || !FXFC_LoadFile(pPackage, m_PredefinedCMap, pBuffer, size)) {
431 return FALSE; 430 return FALSE;
432 } 431 }
433 m_pMapping = FX_Alloc(FX_WORD, 65536); 432 m_pMapping = FX_Alloc(FX_WORD, 65536);
434 FXSYS_memset32(m_pMapping, 0, 65536 * sizeof(FX_WORD));
435 FX_DWORD dwRecodeEndPos = 0; 433 FX_DWORD dwRecodeEndPos = 0;
436 if (pBuffer[5] == 0) { 434 if (pBuffer[5] == 0) {
437 FX_DWORD dwStartIndex = *(FX_DWORD*)(pBuffer + 8); 435 FX_DWORD dwStartIndex = *(FX_DWORD*)(pBuffer + 8);
438 FX_DWORD dwRecordCount = *(FX_DWORD*)(pBuffer + 16); 436 FX_DWORD dwRecordCount = *(FX_DWORD*)(pBuffer + 16);
439 FX_DWORD dwDataOffset = *(FX_DWORD*)(pBuffer + 20); 437 FX_DWORD dwDataOffset = *(FX_DWORD*)(pBuffer + 20);
440 if (dwRecordCount * 2 + dwStartIndex * 2 < 65536) { 438 if (dwRecordCount * 2 + dwStartIndex * 2 < 65536) {
441 FXSYS_memcpy32(m_pMapping + dwStartIndex * 2, pBuffer + dwDataOffset , dwRecordCount * 2); 439 FXSYS_memcpy32(m_pMapping + dwStartIndex * 2, pBuffer + dwDataOffset , dwRecordCount * 2);
442 } 440 }
443 dwRecodeEndPos = dwDataOffset + dwRecordCount * 2; 441 dwRecodeEndPos = dwDataOffset + dwRecordCount * 2;
444 } else if (pBuffer[5] == 2) { 442 } else if (pBuffer[5] == 2) {
(...skipping 28 matching lines...) Expand all
473 } 471 }
474 extern "C" { 472 extern "C" {
475 static int compare_dword(const void* data1, const void* data2) 473 static int compare_dword(const void* data1, const void* data2)
476 { 474 {
477 return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2); 475 return (*(FX_DWORD*)data1) - (*(FX_DWORD*)data2);
478 } 476 }
479 }; 477 };
480 FX_BOOL CPDF_CMap::LoadEmbedded(FX_LPCBYTE pData, FX_DWORD size) 478 FX_BOOL CPDF_CMap::LoadEmbedded(FX_LPCBYTE pData, FX_DWORD size)
481 { 479 {
482 m_pMapping = FX_Alloc(FX_WORD, 65536); 480 m_pMapping = FX_Alloc(FX_WORD, 65536);
483 FXSYS_memset32(m_pMapping, 0, 65536 * sizeof(FX_WORD));
484 CPDF_CMapParser parser; 481 CPDF_CMapParser parser;
485 parser.Initialize(this); 482 parser.Initialize(this);
486 CPDF_SimpleParser syntax(pData, size); 483 CPDF_SimpleParser syntax(pData, size);
487 while (1) { 484 while (1) {
488 CFX_ByteStringC word = syntax.GetWord(); 485 CFX_ByteStringC word = syntax.GetWord();
489 if (word.IsEmpty()) { 486 if (word.IsEmpty()) {
490 break; 487 break;
491 } 488 }
492 parser.ParseWord(word); 489 parser.ParseWord(word);
493 } 490 }
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 m_bType1 = FALSE; 1518 m_bType1 = FALSE;
1522 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapMa nager.GetPredefinedCMap( 1519 m_pCMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals()->m_CMapMa nager.GetPredefinedCMap(
1523 FX_BSTRC("GBK-EUC-H"), FALSE); 1520 FX_BSTRC("GBK-EUC-H"), FALSE);
1524 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals() ->m_CMapManager.GetCID2UnicodeMap(m_Charset, FALSE); 1521 m_pCID2UnicodeMap = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals() ->m_CMapManager.GetCID2UnicodeMap(m_Charset, FALSE);
1525 if (!IsEmbedded()) { 1522 if (!IsEmbedded()) {
1526 LoadSubstFont(); 1523 LoadSubstFont();
1527 } 1524 }
1528 CheckFontMetrics(); 1525 CheckFontMetrics();
1529 m_DefaultWidth = 1000; 1526 m_DefaultWidth = 1000;
1530 m_pAnsiWidths = FX_Alloc(FX_WORD, 128); 1527 m_pAnsiWidths = FX_Alloc(FX_WORD, 128);
1531 FXSYS_memset32(m_pAnsiWidths, 0, 128 * sizeof(FX_WORD));
1532 for (int i = 32; i < 127; i ++) { 1528 for (int i = 32; i < 127; i ++) {
1533 m_pAnsiWidths[i] = 500; 1529 m_pAnsiWidths[i] = 500;
1534 } 1530 }
1535 return TRUE; 1531 return TRUE;
1536 } 1532 }
1537 const struct _CIDTransform { 1533 const struct _CIDTransform {
1538 FX_WORD CID; 1534 FX_WORD CID;
1539 FX_BYTE a, b, c, d, e, f; 1535 FX_BYTE a, b, c, d, e, f;
1540 } 1536 }
1541 Japan1_VertCIDs[] = { 1537 Japan1_VertCIDs[] = {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 if (middlecode > CID) { 1703 if (middlecode > CID) {
1708 end = middle - 1; 1704 end = middle - 1;
1709 } else if (middlecode < CID) { 1705 } else if (middlecode < CID) {
1710 begin = middle + 1; 1706 begin = middle + 1;
1711 } else { 1707 } else {
1712 return &Japan1_VertCIDs[middle].a; 1708 return &Japan1_VertCIDs[middle].a;
1713 } 1709 }
1714 } 1710 }
1715 return NULL; 1711 return NULL;
1716 } 1712 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp ('k') | core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698