summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-09-15 16:24:58 -0700
committerLei Zhang <thestig@chromium.org>2015-09-15 16:24:58 -0700
commit2ccfcae630227d50edb844aefac53ebe450ea15a (patch)
tree04308f348b11aef52f58d19076bd20eb04c579c1
parent7d0fcbf8198f04a5a5bd15482fdbdae919fb1891 (diff)
downloadpdfium-2ccfcae630227d50edb844aefac53ebe450ea15a.tar.xz
Merge to XFA: Cleanup casting of FX_Alloc() return values.
Also convert some FX_AllocOrDie() calls to FX_Alloc(). TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1332173002 . (cherry picked from commit 6aca3e209ff6148f1d77b86b8b97d3bdf18e3eba) Review URL: https://codereview.chromium.org/1344233002 .
-rw-r--r--core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp3
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp2
-rw-r--r--core/src/fpdfapi/fpdf_font/ttgsubtable.cpp2
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp3
-rw-r--r--core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp5
-rw-r--r--core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp36
-rw-r--r--core/src/fxcrt/fx_basic_array.cpp6
7 files changed, 27 insertions, 30 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
index 4ce50a8ac4..79bfbdb13a 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
@@ -128,8 +128,7 @@ void CPDF_PageContentGenerate::TransformContent(CFX_Matrix& matrix) {
if (type == PDFOBJ_ARRAY) {
CPDF_Array* pArray = (CPDF_Array*)pContent;
int iCount = pArray->GetCount();
- CPDF_StreamAcc** pContentArray =
- (CPDF_StreamAcc**)FX_Alloc(CPDF_StreamAcc*, iCount);
+ CPDF_StreamAcc** pContentArray = FX_Alloc(CPDF_StreamAcc*, iCount);
int size = 0;
int i = 0;
for (i = 0; i < iCount; ++i) {
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index c934124a8a..0744c896ce 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -1251,7 +1251,7 @@ int CPDF_CIDFont::GetGlyphIndex(FX_DWORD unicode, FX_BOOL* pVertGlyph) {
int error = FXFT_Load_Sfnt_Table(
m_Font.m_Face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, NULL, &length);
if (!error) {
- m_Font.m_pGsubData = (unsigned char*)FX_Alloc(uint8_t, length);
+ m_Font.m_pGsubData = FX_Alloc(uint8_t, length);
}
}
int error =
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
index 81383fa869..2ed586e0a3 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -393,7 +393,7 @@ IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont) {
int error = FXFT_Load_Sfnt_Table(
pFont->m_Face, FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, NULL, &length);
if (!error) {
- pFont->m_pGsubData = (unsigned char*)FX_Alloc(uint8_t, length);
+ pFont->m_pGsubData = FX_Alloc(uint8_t, length);
}
if (!pFont->m_pGsubData) {
return NULL;
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 17e2bcf356..db0c2eae4b 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -676,8 +676,7 @@ void* CCodec_JpegModule::Start() {
if (m_pExtProvider) {
return m_pExtProvider->Start();
}
- FXJPEG_Context* p =
- (FXJPEG_Context*)FX_Alloc(uint8_t, sizeof(FXJPEG_Context));
+ FXJPEG_Context* p = FX_Alloc(FXJPEG_Context, 1);
p->m_AllocFunc = jpeg_alloc_func;
p->m_FreeFunc = jpeg_free_func;
p->m_ErrMgr.error_exit = _error_fatal1;
diff --git a/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp
index d12ab5a2e8..c8baa158e9 100644
--- a/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp
@@ -9,7 +9,7 @@
#include "../../../include/fxcrt/fx_memory.h"
CJBig2_ArithIntDecoder::CJBig2_ArithIntDecoder() {
- IAx = (JBig2ArithCtx*)FX_AllocOrDie(sizeof(JBig2ArithCtx), 512);
+ IAx = FX_Alloc(JBig2ArithCtx, 512);
JBIG2_memset(IAx, 0, sizeof(JBig2ArithCtx) * 512);
}
CJBig2_ArithIntDecoder::~CJBig2_ArithIntDecoder() {
@@ -82,8 +82,7 @@ int CJBig2_ArithIntDecoder::decode(CJBig2_ArithDecoder* pArithDecoder,
}
CJBig2_ArithIaidDecoder::CJBig2_ArithIaidDecoder(unsigned char SBSYMCODELENA) {
SBSYMCODELEN = SBSYMCODELENA;
- IAID =
- (JBig2ArithCtx*)FX_AllocOrDie(sizeof(JBig2ArithCtx), (1 << SBSYMCODELEN));
+ IAID = FX_Alloc(JBig2ArithCtx, 1 << SBSYMCODELEN);
JBIG2_memset(IAID, 0, sizeof(JBig2ArithCtx) * (int)(1 << SBSYMCODELEN));
}
CJBig2_ArithIaidDecoder::~CJBig2_ArithIaidDecoder() {
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
index ea1fdee3be..704145806a 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp
@@ -45,10 +45,10 @@ int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
int* FIRSTCODE;
HTOOB = bHTOOB;
NTEMP = nLines;
- 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);
+ CODES = FX_Alloc(int, NTEMP);
+ PREFLEN = FX_Alloc(int, NTEMP);
+ RANGELEN = FX_Alloc(int, NTEMP);
+ RANGELOW = FX_Alloc(int, NTEMP);
LENMAX = 0;
for (i = 0; i < NTEMP; i++) {
PREFLEN[i] = pTable[i].PREFLEN;
@@ -58,9 +58,9 @@ int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
LENMAX = PREFLEN[i];
}
}
- LENCOUNT = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
+ LENCOUNT = FX_Alloc(int, LENMAX + 1);
JBIG2_memset(LENCOUNT, 0, sizeof(int) * (LENMAX + 1));
- FIRSTCODE = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
+ FIRSTCODE = FX_Alloc(int, LENMAX + 1);
for (i = 0; i < NTEMP; i++) {
LENCOUNT[PREFLEN[i]]++;
}
@@ -85,12 +85,12 @@ int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
return 1;
}
-#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); \
+#define HT_CHECK_MEMORY_ADJUST \
+ if (NTEMP >= nSize) { \
+ nSize += 16; \
+ PREFLEN = FX_Realloc(int, PREFLEN, nSize); \
+ RANGELEN = FX_Realloc(int, RANGELEN, nSize); \
+ RANGELOW = FX_Realloc(int, RANGELOW, nSize); \
}
int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
unsigned char HTPS, HTRS;
@@ -111,9 +111,9 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
pStream->readInteger(&HTHIGH) == -1 || HTLOW > HTHIGH) {
goto failed;
}
- PREFLEN = (int*)FX_AllocOrDie(sizeof(int), nSize);
- RANGELEN = (int*)FX_AllocOrDie(sizeof(int), nSize);
- RANGELOW = (int*)FX_AllocOrDie(sizeof(int), nSize);
+ PREFLEN = FX_Alloc(int, nSize);
+ RANGELEN = FX_Alloc(int, nSize);
+ RANGELOW = FX_Alloc(int, nSize);
CURRANGELOW = HTLOW;
NTEMP = 0;
do {
@@ -147,16 +147,16 @@ int CJBig2_HuffmanTable::parseFromCodedBuffer(CJBig2_BitStream* pStream) {
}
NTEMP = NTEMP + 1;
}
- CODES = (int*)FX_AllocOrDie(sizeof(int), NTEMP);
+ CODES = FX_Alloc(int, NTEMP);
LENMAX = 0;
for (int i = 0; i < NTEMP; i++) {
if (PREFLEN[i] > LENMAX) {
LENMAX = PREFLEN[i];
}
}
- LENCOUNT = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
+ LENCOUNT = FX_Alloc(int, (LENMAX + 1));
JBIG2_memset(LENCOUNT, 0, sizeof(int) * (LENMAX + 1));
- FIRSTCODE = (int*)FX_AllocOrDie(sizeof(int), (LENMAX + 1));
+ FIRSTCODE = FX_Alloc(int, (LENMAX + 1));
for (int i = 0; i < NTEMP; i++) {
LENCOUNT[PREFLEN[i]]++;
}
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index 5555ed2586..eeaa74926a 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -187,7 +187,7 @@ void* CFX_BaseSegmentedArray::Add() {
return pSegment;
}
if (m_IndexDepth == 0) {
- void** pIndex = (void**)FX_Alloc(void*, m_IndexSize);
+ void** pIndex = FX_Alloc(void*, m_IndexSize);
pIndex[0] = m_pIndex;
pIndex[1] = pSegment;
m_pIndex = pIndex;
@@ -208,7 +208,7 @@ void* CFX_BaseSegmentedArray::Add() {
tree_size *= m_IndexSize;
}
if (m_DataSize == tree_size * m_SegmentSize) {
- void** pIndex = (void**)FX_Alloc(void*, m_IndexSize);
+ void** pIndex = FX_Alloc(void*, m_IndexSize);
pIndex[0] = m_pIndex;
m_pIndex = pIndex;
m_IndexDepth++;
@@ -218,7 +218,7 @@ void* CFX_BaseSegmentedArray::Add() {
void** pSpot = (void**)m_pIndex;
for (i = 1; i < m_IndexDepth; i++) {
if (pSpot[seg_index / tree_size] == NULL) {
- pSpot[seg_index / tree_size] = (void*)FX_Alloc(void*, m_IndexSize);
+ pSpot[seg_index / tree_size] = FX_Alloc(void*, m_IndexSize);
}
pSpot = (void**)pSpot[seg_index / tree_size];
seg_index = seg_index % tree_size;