From 2ccfcae630227d50edb844aefac53ebe450ea15a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 15 Sep 2015 16:24:58 -0700 Subject: 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 . --- core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp | 5 ++-- core/src/fxcodec/jbig2/JBig2_HuffmanTable.cpp | 36 ++++++++++++------------ 2 files changed, 20 insertions(+), 21 deletions(-) (limited to 'core/src/fxcodec/jbig2') 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]]++; } -- cgit v1.2.3