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

Unified Diff: core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp

Issue 1332153002: Merge to XFA: Make a bunch of JBig2 classes independent of CJBig2_Object. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanTable.h ('k') | core/src/fxcodec/jbig2/JBig2_List.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
index 87722d262808309d76f83d8a54f9a2cccc589df6..ea1fdee3beee0ac324ec52fdb66e130ce5dddc0f 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
@@ -5,9 +5,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "JBig2_HuffmanTable.h"
-#include "JBig2_BitStream.h"
+
#include <string.h>
+#include "../../../include/fxcrt/fx_memory.h"
+#include "JBig2_BitStream.h"
+
CJBig2_HuffmanTable::CJBig2_HuffmanTable(const JBig2TableLine* pTable,
int nLines,
FX_BOOL bHTOOB) {
@@ -21,18 +24,10 @@ CJBig2_HuffmanTable::CJBig2_HuffmanTable(CJBig2_BitStream* pStream) {
}
CJBig2_HuffmanTable::~CJBig2_HuffmanTable() {
- if (CODES) {
- m_pModule->JBig2_Free(CODES);
- }
- if (PREFLEN) {
- m_pModule->JBig2_Free(PREFLEN);
- }
- if (RANGELEN) {
- m_pModule->JBig2_Free(RANGELEN);
- }
- if (RANGELOW) {
- m_pModule->JBig2_Free(RANGELOW);
- }
+ FX_Free(CODES);
+ FX_Free(PREFLEN);
+ FX_Free(RANGELEN);
+ FX_Free(RANGELOW);
}
void CJBig2_HuffmanTable::init() {
HTOOB = FALSE;
@@ -50,10 +45,10 @@ int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
int* FIRSTCODE;
HTOOB = bHTOOB;
NTEMP = nLines;
- CODES = (int*)m_pModule->JBig2_Malloc2(sizeof(int), NTEMP);
- PREFLEN = (int*)m_pModule->JBig2_Malloc2(sizeof(int), NTEMP);
- RANGELEN = (int*)m_pModule->JBig2_Malloc2(sizeof(int), NTEMP);
- RANGELOW = (int*)m_pModule->JBig2_Malloc2(sizeof(int), NTEMP);
+ CODES = (int*)FX_AllocOrDie(sizeof(int), NTEMP);
+ PREFLEN = (int*)FX_AllocOrDie(sizeof(int), NTEMP);
+ RANGELEN = (int*)FX_AllocOrDie(sizeof(int), NTEMP);
+ RANGELOW = (int*)FX_AllocOrDie(sizeof(int), NTEMP);
LENMAX = 0;
for (i = 0; i < NTEMP; i++) {
PREFLEN[i] = pTable[i].PREFLEN;
@@ -63,9 +58,9 @@ int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
LENMAX = PREFLEN[i];
}
}
- LENCOUNT = (int*)m_pModule->JBig2_Malloc2(sizeof(int), (LENMAX + 1));
+ LENCOUNT = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
JBIG2_memset(LENCOUNT, 0, sizeof(int) * (LENMAX + 1));
- FIRSTCODE = (int*)m_pModule->JBig2_Malloc2(sizeof(int), (LENMAX + 1));
+ FIRSTCODE = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
for (i = 0; i < NTEMP; i++) {
LENCOUNT[PREFLEN[i]]++;
}
@@ -85,17 +80,17 @@ int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
}
CURLEN = CURLEN + 1;
}
- m_pModule->JBig2_Free(LENCOUNT);
- m_pModule->JBig2_Free(FIRSTCODE);
+ FX_Free(LENCOUNT);
+ FX_Free(FIRSTCODE);
return 1;
}
-#define HT_CHECK_MEMORY_ADJUST \
- if (NTEMP >= nSize) { \
- nSize += 16; \
- PREFLEN = (int*)m_pModule->JBig2_Realloc(PREFLEN, sizeof(int) * nSize); \
- RANGELEN = (int*)m_pModule->JBig2_Realloc(RANGELEN, sizeof(int) * nSize); \
- RANGELOW = (int*)m_pModule->JBig2_Realloc(RANGELOW, sizeof(int) * nSize); \
+#define HT_CHECK_MEMORY_ADJUST \
+ if (NTEMP >= nSize) { \
+ nSize += 16; \
+ PREFLEN = (int*)FX_Realloc(uint8_t, PREFLEN, sizeof(int) * nSize); \
+ RANGELEN = (int*)FX_Realloc(uint8_t, RANGELEN, sizeof(int) * nSize); \
+ RANGELOW = (int*)FX_Realloc(uint8_t, RANGELOW, sizeof(int) * nSize); \
}
int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
unsigned char HTPS, HTRS;
@@ -116,9 +111,9 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
pStream->readInteger(&HTHIGH) == -1 || HTLOW > HTHIGH) {
goto failed;
}
- PREFLEN = (int*)m_pModule->JBig2_Malloc2(sizeof(int), nSize);
- RANGELEN = (int*)m_pModule->JBig2_Malloc2(sizeof(int), nSize);
- RANGELOW = (int*)m_pModule->JBig2_Malloc2(sizeof(int), nSize);
+ PREFLEN = (int*)FX_AllocOrDie(sizeof(int), nSize);
+ RANGELEN = (int*)FX_AllocOrDie(sizeof(int), nSize);
+ RANGELOW = (int*)FX_AllocOrDie(sizeof(int), nSize);
CURRANGELOW = HTLOW;
NTEMP = 0;
do {
@@ -152,16 +147,16 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
}
NTEMP = NTEMP + 1;
}
- CODES = (int*)m_pModule->JBig2_Malloc2(sizeof(int), NTEMP);
+ CODES = (int*)FX_AllocOrDie(sizeof(int), NTEMP);
LENMAX = 0;
for (int i = 0; i < NTEMP; i++) {
if (PREFLEN[i] > LENMAX) {
LENMAX = PREFLEN[i];
}
}
- LENCOUNT = (int*)m_pModule->JBig2_Malloc2(sizeof(int), (LENMAX + 1));
+ LENCOUNT = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
JBIG2_memset(LENCOUNT, 0, sizeof(int) * (LENMAX + 1));
- FIRSTCODE = (int*)m_pModule->JBig2_Malloc2(sizeof(int), (LENMAX + 1));
+ FIRSTCODE = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
for (int i = 0; i < NTEMP; i++) {
LENCOUNT[PREFLEN[i]]++;
}
@@ -181,8 +176,8 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
}
CURLEN = CURLEN + 1;
}
- m_pModule->JBig2_Free(LENCOUNT);
- m_pModule->JBig2_Free(FIRSTCODE);
+ FX_Free(LENCOUNT);
+ FX_Free(FIRSTCODE);
return TRUE;
failed:
return FALSE;
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanTable.h ('k') | core/src/fxcodec/jbig2/JBig2_List.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698