本文整理汇总了C++中FX_Alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ FX_Alloc函数的具体用法?C++ FX_Alloc怎么用?C++ FX_Alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FX_Alloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FX_Alloc
int32_t CFDE_TxtEdtPage::GetDisplayPos(const CFX_RectF& rtClip,
FXTEXT_CHARPOS*& pCharPos,
CFX_RectF* pBBox) const {
pCharPos = FX_Alloc(FXTEXT_CHARPOS, m_nCharCount);
int32_t nCharPosCount = 0;
FDE_TEXTEDITPIECE* pPiece = nullptr;
int32_t nVisualObjCount = m_PieceMassArr.GetSize();
FXTEXT_CHARPOS* pos = pCharPos;
CFX_RectF rtObj;
for (int32_t i = 0; i < nVisualObjCount; i++) {
pPiece = m_PieceMassArr.GetPtrAt(i);
m_pTextSet->GetRect(pPiece, rtObj);
if (!rtClip.IntersectWith(rtObj)) {
continue;
}
int32_t nCount = m_pTextSet->GetDisplayPos(pPiece, pos, FALSE);
nCharPosCount += nCount;
pos += nCount;
}
if ((nCharPosCount * 5) < (m_nCharCount << 2)) {
FXTEXT_CHARPOS* pTemp = FX_Alloc(FXTEXT_CHARPOS, nCharPosCount);
FXSYS_memcpy(pTemp, pCharPos, sizeof(FXTEXT_CHARPOS) * nCharPosCount);
FX_Free(pCharPos);
pCharPos = pTemp;
}
return nCharPosCount;
}
示例2: FX_Alloc
FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj)
{
CPDF_Dictionary* pDict = pObj->GetDict();
if (pDict == NULL) {
return FALSE;
}
CPDF_Array* pArray0 = pDict->GetArray(FX_BSTRC("C0"));
if (m_nOutputs == 0) {
m_nOutputs = 1;
if (pArray0) {
m_nOutputs = pArray0->GetCount();
}
}
CPDF_Array* pArray1 = pDict->GetArray(FX_BSTRC("C1"));
m_pBeginValues = FX_Alloc(FX_FLOAT, m_nOutputs * 2);
m_pEndValues = FX_Alloc(FX_FLOAT, m_nOutputs * 2);
for (int i = 0; i < m_nOutputs; i ++) {
m_pBeginValues[i] = pArray0 ? pArray0->GetFloat(i) : 0.0f;
m_pEndValues[i] = pArray1 ? pArray1->GetFloat(i) : 1.0f;
}
m_Exponent = pDict->GetFloat(FX_BSTRC("N"));
m_nOrigOutputs = m_nOutputs;
if (m_nOutputs && m_nInputs > INT_MAX / m_nOutputs) {
return FALSE;
}
m_nOutputs *= m_nInputs;
return TRUE;
}
示例3: FX_Free
void CPDF_TextObject::SetText(int nChars,
FX_DWORD* pCharCodes,
FX_FLOAT* pKernings) {
if (m_nChars > 1) {
FX_Free(m_pCharCodes);
m_pCharCodes = nullptr;
}
FX_Free(m_pCharPos);
m_pCharPos = nullptr;
int nKernings = 0;
int i;
for (i = 0; i < nChars - 1; ++i) {
if (pKernings[i] != 0) {
++nKernings;
}
}
m_nChars = nChars + nKernings;
if (m_nChars > 1) {
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
for (int i = 0, index = 0; i < nChars; ++i) {
m_pCharCodes[index++] = pCharCodes[i];
if (pKernings[i] != 0 && i != nChars - 1) {
m_pCharCodes[index] = (FX_DWORD)-1;
m_pCharPos[index - 1] = pKernings[i];
++index;
}
}
} else {
m_pCharCodes = (FX_DWORD*)(uintptr_t)pCharCodes[0];
}
RecalcPositionData();
}
示例4: FX_Free
void CPDF_TextObject::SetText(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pKernings)
{
if (m_nChars > 1 && m_pCharCodes) {
FX_Free(m_pCharCodes);
m_pCharCodes = NULL;
}
if (m_pCharPos) {
FX_Free(m_pCharPos);
m_pCharPos = NULL;
}
int nKernings = 0;
int i;
for (i = 0; i < nChars - 1; i ++)
if (pKernings[i] != 0) {
nKernings ++;
}
m_nChars = nChars + nKernings;
if (m_nChars > 1) {
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
int index = 0;
for (int i = 0; i < nChars; i ++) {
m_pCharCodes[index++] = pCharCodes[i];
if (pKernings[i] != 0 && i != nChars - 1) {
m_pCharCodes[index] = (FX_DWORD) - 1;
m_pCharPos[index - 1] = pKernings[i];
index ++;
}
}
} else {
m_pCharCodes = (FX_DWORD*)(FX_UINTPTR)pCharCodes[0];
}
RecalcPositionData();
}
示例5: FX_Free
void CPDF_TextObject::CopyData(const CPDF_PageObject* pSrc)
{
const CPDF_TextObject* pSrcObj = (const CPDF_TextObject*)pSrc;
if (m_nChars > 1 && m_pCharCodes) {
FX_Free(m_pCharCodes);
m_pCharCodes = nullptr;
}
if (m_pCharPos) {
FX_Free(m_pCharPos);
m_pCharPos = nullptr;
}
m_nChars = pSrcObj->m_nChars;
if (m_nChars > 1) {
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
for (int i = 0; i < m_nChars; ++i) {
m_pCharCodes[i] = pSrcObj->m_pCharCodes[i];
}
for (int i = 0; i < m_nChars - 1; ++i) {
m_pCharPos[i] = pSrcObj->m_pCharPos[i];
}
} else {
m_pCharCodes = pSrcObj->m_pCharCodes;
}
m_PosX = pSrcObj->m_PosX;
m_PosY = pSrcObj->m_PosY;
}
示例6: FX_Alloc
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
if (pObj->GetType() != PDFOBJ_STREAM) {
return FALSE;
}
CPDF_Stream* pStream = (CPDF_Stream*)pObj;
CPDF_Dictionary* pDict = pStream->GetDict();
CPDF_Array* pSize = pDict->GetArray(FX_BSTRC("Size"));
CPDF_Array* pEncode = pDict->GetArray(FX_BSTRC("Encode"));
CPDF_Array* pDecode = pDict->GetArray(FX_BSTRC("Decode"));
m_nBitsPerSample = pDict->GetInteger(FX_BSTRC("BitsPerSample"));
if (m_nBitsPerSample > 32) {
return FALSE;
}
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
m_pSampleStream = new CPDF_StreamAcc;
m_pSampleStream->LoadAllData(pStream, FALSE);
m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs);
FX_SAFE_DWORD nTotalSampleBits = 1;
for (int i = 0; i < m_nInputs; i++) {
m_pEncodeInfo[i].sizes = pSize ? pSize->GetInteger(i) : 0;
if (!pSize && i == 0) {
m_pEncodeInfo[i].sizes = pDict->GetInteger(FX_BSTRC("Size"));
}
nTotalSampleBits *= m_pEncodeInfo[i].sizes;
if (pEncode) {
m_pEncodeInfo[i].encode_min = pEncode->GetFloat(i * 2);
m_pEncodeInfo[i].encode_max = pEncode->GetFloat(i * 2 + 1);
} else {
m_pEncodeInfo[i].encode_min = 0;
if (m_pEncodeInfo[i].sizes == 1) {
m_pEncodeInfo[i].encode_max = 1;
} else {
m_pEncodeInfo[i].encode_max = (FX_FLOAT)m_pEncodeInfo[i].sizes - 1;
}
}
}
nTotalSampleBits *= m_nBitsPerSample;
nTotalSampleBits *= m_nOutputs;
FX_SAFE_DWORD nTotalSampleBytes = nTotalSampleBits;
nTotalSampleBytes += 7;
nTotalSampleBytes /= 8;
if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 ||
nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) {
return FALSE;
}
m_pDecodeInfo = FX_Alloc(SampleDecodeInfo, m_nOutputs);
for (int i = 0; i < m_nOutputs; i++) {
if (pDecode) {
m_pDecodeInfo[i].decode_min = pDecode->GetFloat(2 * i);
m_pDecodeInfo[i].decode_max = pDecode->GetFloat(2 * i + 1);
} else {
m_pDecodeInfo[i].decode_min = m_pRanges[i * 2];
m_pDecodeInfo[i].decode_max = m_pRanges[i * 2 + 1];
}
}
return TRUE;
}
示例7: FX_Alloc
void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
FX_FLOAT origin_x,
FX_FLOAT origin_y,
CPDF_Font* pFont,
FX_FLOAT font_size,
const CFX_AffineMatrix* pMatrix,
const CFX_ByteString& str,
FX_ARGB fill_argb,
FX_ARGB stroke_argb,
const CFX_GraphStateData* pGraphState,
const CPDF_RenderOptions* pOptions) {
int nChars = pFont->CountChar(str, str.GetLength());
if (nChars == 0) {
return;
}
FX_DWORD charcode;
int offset = 0;
FX_DWORD* pCharCodes;
FX_FLOAT* pCharPos;
if (nChars == 1) {
charcode = pFont->GetNextChar(str, str.GetLength(), offset);
pCharCodes = (FX_DWORD*)(uintptr_t)charcode;
pCharPos = NULL;
} else {
pCharCodes = FX_Alloc(FX_DWORD, nChars);
pCharPos = FX_Alloc(FX_FLOAT, nChars - 1);
FX_FLOAT cur_pos = 0;
for (int i = 0; i < nChars; i++) {
pCharCodes[i] = pFont->GetNextChar(str, str.GetLength(), offset);
if (i) {
pCharPos[i - 1] = cur_pos;
}
cur_pos += pFont->GetCharWidthF(pCharCodes[i]) * font_size / 1000;
}
}
CFX_AffineMatrix matrix;
if (pMatrix) {
matrix = *pMatrix;
}
matrix.e = origin_x;
matrix.f = origin_y;
if (pFont->GetFontType() == PDFFONT_TYPE3)
;
else if (stroke_argb == 0) {
DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size,
&matrix, fill_argb, pOptions);
} else
DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size,
&matrix, NULL, pGraphState, fill_argb, stroke_argb, NULL);
if (nChars > 1) {
FX_Free(pCharCodes);
FX_Free(pCharPos);
}
}
示例8: m_File
CFX_SAXReader::CFX_SAXReader()
: m_File(),
m_pHandler(nullptr),
m_iState(-1),
m_pRoot(nullptr),
m_pCurItem(nullptr),
m_dwItemID(0),
m_iDataSize(256),
m_iNameSize(256),
m_dwParseMode(0),
m_pCommentContext(nullptr) {
m_pszData = FX_Alloc(uint8_t, m_iDataSize);
m_pszName = FX_Alloc(uint8_t, m_iNameSize);
}
示例9: FX_Alloc
void* CPDF_CryptoHandler::CryptStart(uint32_t objnum,
uint32_t gennum,
bool bEncrypt) {
if (m_Cipher == FXCIPHER_NONE) {
return this;
}
if (m_Cipher == FXCIPHER_AES && m_KeyLen == 32) {
AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1);
pContext->m_bIV = true;
pContext->m_BlockOffset = 0;
CRYPT_AESSetKey(pContext->m_Context, 16, m_EncryptKey, 32, bEncrypt);
if (bEncrypt) {
for (int i = 0; i < 16; i++) {
pContext->m_Block[i] = (uint8_t)rand();
}
CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block);
}
return pContext;
}
uint8_t key1[48];
PopulateKey(objnum, gennum, key1);
if (m_Cipher == FXCIPHER_AES) {
FXSYS_memcpy(key1 + m_KeyLen + 5, "sAlT", 4);
}
uint8_t realkey[16];
CRYPT_MD5Generate(
key1, m_Cipher == FXCIPHER_AES ? m_KeyLen + 9 : m_KeyLen + 5, realkey);
int realkeylen = m_KeyLen + 5;
if (realkeylen > 16) {
realkeylen = 16;
}
if (m_Cipher == FXCIPHER_AES) {
AESCryptContext* pContext = FX_Alloc(AESCryptContext, 1);
pContext->m_bIV = true;
pContext->m_BlockOffset = 0;
CRYPT_AESSetKey(pContext->m_Context, 16, realkey, 16, bEncrypt);
if (bEncrypt) {
for (int i = 0; i < 16; i++) {
pContext->m_Block[i] = (uint8_t)rand();
}
CRYPT_AESSetIV(pContext->m_Context, pContext->m_Block);
}
return pContext;
}
CRYPT_rc4_context* pContext = FX_Alloc(CRYPT_rc4_context, 1);
CRYPT_ArcFourSetup(pContext, realkey, realkeylen);
return pContext;
}
示例10: FX_Alloc
void CPDF_StandardSecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict, FX_DWORD permissions,
FX_BOOL bEncryptMetadata, FX_LPCBYTE key)
{
FX_BYTE buf[16];
buf[0] = (FX_BYTE)permissions;
buf[1] = (FX_BYTE)(permissions >> 8);
buf[2] = (FX_BYTE)(permissions >> 16);
buf[3] = (FX_BYTE)(permissions >> 24);
buf[4] = 0xff;
buf[5] = 0xff;
buf[6] = 0xff;
buf[7] = 0xff;
buf[8] = bEncryptMetadata ? 'T' : 'F';
buf[9] = 'a';
buf[10] = 'd';
buf[11] = 'b';
FX_BYTE* aes = FX_Alloc(FX_BYTE, 2048);
CRYPT_AESSetKey(aes, 16, key, 32, TRUE);
FX_BYTE iv[16], buf1[16];
FXSYS_memset32(iv, 0, 16);
CRYPT_AESSetIV(aes, iv);
CRYPT_AESEncrypt(aes, buf1, buf, 16);
FX_Free(aes);
pEncryptDict->SetAtString(FX_BSTRC("Perms"), CFX_ByteString(buf1, 16));
}
示例11: FX_Alloc
FX_BOOL CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf,
FX_DWORD src_size,
int width,
int height,
int nComps,
int bpc) {
m_pSrcBuf = src_buf;
m_SrcSize = src_size;
m_OutputWidth = m_OrigWidth = width;
m_OutputHeight = m_OrigHeight = height;
m_nComps = nComps;
m_bpc = bpc;
m_bColorTransformed = FALSE;
m_DownScale = 1;
// Aligning the pitch to 4 bytes requires an integer overflow check.
FX_SAFE_DWORD pitch = width;
pitch *= nComps;
pitch *= bpc;
pitch += 31;
pitch /= 32;
pitch *= 4;
if (!pitch.IsValid()) {
return FALSE;
}
m_Pitch = pitch.ValueOrDie();
// Overflow should already have been checked before this is called.
m_dwLineBytes = (static_cast<FX_DWORD>(width) * nComps * bpc + 7) / 8;
m_pScanline = FX_Alloc(uint8_t, m_Pitch);
return CheckDestSize();
}
示例12: CacheOptimization
void CPDF_PageRenderCache::CacheOptimization(FX_INT32 dwLimitCacheSize)
{
if (m_nCacheSize <= (FX_DWORD)dwLimitCacheSize) {
return;
}
int nCount = m_ImageCaches.GetCount();
CACHEINFO* pCACHEINFO = (CACHEINFO*)FX_Alloc(FX_BYTE, (sizeof (CACHEINFO)) * nCount);
FX_POSITION pos = m_ImageCaches.GetStartPosition();
int i = 0;
while (pos) {
FX_LPVOID key, value;
m_ImageCaches.GetNextAssoc(pos, key, value);
pCACHEINFO[i].time = ((CPDF_ImageCache*)value)->GetTimeCount();
pCACHEINFO[i++].pStream = ((CPDF_ImageCache*)value)->GetStream();
}
FXSYS_qsort(pCACHEINFO, nCount, sizeof (CACHEINFO), compare);
FX_DWORD nTimeCount = m_nTimeCount;
if (nTimeCount + 1 < nTimeCount) {
for (i = 0; i < nCount; i ++) {
((CPDF_ImageCache*)(m_ImageCaches[pCACHEINFO[i].pStream]))->m_dwTimeCount = i;
}
m_nTimeCount = nCount;
}
i = 0;
while(nCount > 15) {
ClearImageCache(pCACHEINFO[i++].pStream);
nCount--;
}
while (m_nCacheSize > (FX_DWORD)dwLimitCacheSize) {
ClearImageCache(pCACHEINFO[i++].pStream);
}
FX_Free(pCACHEINFO);
}
示例13: FX_Free
void CPDF_Stream::SetData(FX_LPCBYTE pData, FX_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf)
{
if (m_GenNum == (FX_DWORD) - 1) {
if (m_pDataBuf) {
FX_Free(m_pDataBuf);
}
} else {
m_GenNum = (FX_DWORD) - 1;
m_pCryptoHandler = NULL;
}
if (bKeepBuf) {
m_pDataBuf = (FX_LPBYTE)pData;
} else {
m_pDataBuf = FX_Alloc(FX_BYTE, size);
if (pData) {
FXSYS_memcpy32(m_pDataBuf, pData, size);
}
}
m_dwSize = size;
if (m_pDict == NULL) {
m_pDict = new CPDF_Dictionary;
}
m_pDict->SetAtInteger(FX_BSTRC("Length"), size);
if (!bCompressed) {
m_pDict->RemoveAt(FX_BSTRC("Filter"));
m_pDict->RemoveAt(FX_BSTRC("DecodeParms"));
}
}
示例14: FX_File_Copy
FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst)
{
CFXCRT_FileAccess_CRT src, dst;
if (!src.Open(fileNameSrc, FX_FILEMODE_ReadOnly)) {
return FALSE;
}
FX_FILESIZE size = src.GetSize();
if (!size) {
return FALSE;
}
if (!dst.Open(fileNameDst, FX_FILEMODE_Truncate)) {
return FALSE;
}
FX_FILESIZE num = 0;
FX_LPBYTE pBuffer = FX_Alloc(FX_BYTE, 32768);
if (!pBuffer) {
return FALSE;
}
while (num = src.Read(pBuffer, 32768)) {
if (dst.Write(pBuffer, num) != num) {
break;
}
}
FX_Free(pBuffer);
return TRUE;
}
示例15: FX_Free
void CPDF_Stream::SetData(const uint8_t* pData,
uint32_t size,
FX_BOOL bCompressed,
FX_BOOL bKeepBuf) {
if (IsMemoryBased())
FX_Free(m_pDataBuf);
m_GenNum = kMemoryBasedGenNum;
if (bKeepBuf) {
m_pDataBuf = const_cast<uint8_t*>(pData);
} else {
m_pDataBuf = FX_Alloc(uint8_t, size);
if (pData) {
FXSYS_memcpy(m_pDataBuf, pData, size);
}
}
m_dwSize = size;
if (!m_pDict)
m_pDict = new CPDF_Dictionary;
m_pDict->SetAtInteger("Length", size);
if (!bCompressed) {
m_pDict->RemoveAt("Filter");
m_pDict->RemoveAt("DecodeParms");
}
}