本文整理汇总了C++中HPDF_GetMem函数的典型用法代码示例。如果您正苦于以下问题:C++ HPDF_GetMem函数的具体用法?C++ HPDF_GetMem怎么用?C++ HPDF_GetMem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HPDF_GetMem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HPDF_Type1FontDef_New
HPDF_FontDef
HPDF_Type1FontDef_New (HPDF_MMgr mmgr)
{
HPDF_FontDef fontdef;
HPDF_Type1FontDefAttr fontdef_attr;
HPDF_PTRACE (" HPDF_Type1FontDef_New\n");
if (!mmgr)
return NULL;
fontdef = HPDF_GetMem (mmgr, sizeof(HPDF_FontDef_Rec));
if (!fontdef)
return NULL;
HPDF_MemSet (fontdef, 0, sizeof (HPDF_FontDef_Rec));
fontdef->sig_bytes = HPDF_FONTDEF_SIG_BYTES;
fontdef->mmgr = mmgr;
fontdef->error = mmgr->error;
fontdef->type = HPDF_FONTDEF_TYPE_TYPE1;
fontdef->free_fn = FreeFunc;
fontdef_attr = HPDF_GetMem (mmgr, sizeof(HPDF_Type1FontDefAttr_Rec));
if (!fontdef_attr) {
HPDF_FreeMem (fontdef->mmgr, fontdef);
return NULL;
}
fontdef->attr = fontdef_attr;
HPDF_MemSet ((HPDF_BYTE *)fontdef_attr, 0, sizeof(HPDF_Type1FontDefAttr_Rec));
fontdef->flags = HPDF_FONT_STD_CHARSET;
return fontdef;
}
示例2: ReadTransparentPaletteData
static HPDF_STATUS
ReadTransparentPaletteData (HPDF_Dict image,
png_structp png_ptr,
png_infop info_ptr,
png_bytep smask_data,
png_bytep trans,
int num_trans)
{
HPDF_STATUS ret = HPDF_OK;
HPDF_UINT i, j;
png_bytep *row_ptr;
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
png_uint_32 width = png_get_image_width(png_ptr, info_ptr);
row_ptr = HPDF_GetMem (image->mmgr, height * sizeof(png_bytep));
if (!row_ptr) {
return HPDF_FAILD_TO_ALLOC_MEM;
} else {
png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr);
for (i = 0; i < (HPDF_UINT)height; i++) {
row_ptr[i] = HPDF_GetMem(image->mmgr, len);
if (!row_ptr[i]) {
for (; i > 0; i--) {
HPDF_FreeMem (image->mmgr, row_ptr[i]);
}
HPDF_FreeMem (image->mmgr, row_ptr);
return HPDF_FAILD_TO_ALLOC_MEM;
}
}
}
png_read_image(png_ptr, row_ptr);
if (image->error->error_no != HPDF_OK) {
ret = HPDF_INVALID_PNG_IMAGE;
goto Error;
}
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
smask_data[width * j + i] = (row_ptr[j][i] < num_trans) ? trans[row_ptr[j][i]] : 0xFF;
}
if (HPDF_Stream_Write (image->stream, row_ptr[j], width) != HPDF_OK) {
ret = HPDF_FILE_IO_ERROR;
goto Error;
}
}
Error:
for (i = 0; i < (HPDF_UINT)height; i++) {
HPDF_FreeMem (image->mmgr, row_ptr[i]);
}
HPDF_FreeMem (image->mmgr, row_ptr);
return ret;
}
示例3: HPDF_Xref_New
HPDF_Xref
HPDF_Xref_New (HPDF_MMgr mmgr,
HPDF_UINT32 offset)
{
HPDF_Xref xref;
HPDF_XrefEntry new_entry;
HPDF_PTRACE((" HPDF_Xref_New\n"));
xref = (HPDF_Xref)HPDF_GetMem (mmgr, sizeof(HPDF_Xref_Rec));
if (!xref)
return NULL;
HPDF_MemSet (xref, 0, sizeof(HPDF_Xref_Rec));
xref->mmgr = mmgr;
xref->error = mmgr->error;
xref->start_offset = offset;
xref->entries = HPDF_List_New (mmgr, HPDF_DEFALUT_XREF_ENTRY_NUM);
if (!xref->entries)
goto Fail;
xref->addr = 0;
if (xref->start_offset == 0) {
new_entry = (HPDF_XrefEntry)HPDF_GetMem (mmgr,
sizeof(HPDF_XrefEntry_Rec));
if (!new_entry)
goto Fail;
if (HPDF_List_Add (xref->entries, new_entry) != HPDF_OK) {
HPDF_FreeMem (mmgr, new_entry);
goto Fail;
}
/* add first entry which is free entry and whose generation
* number is 0
*/
new_entry->entry_typ = HPDF_FREE_ENTRY;
new_entry->byte_offset = 0;
new_entry->gen_no = HPDF_MAX_GENERATION_NUM;
new_entry->obj = NULL;
}
xref->trailer = HPDF_Dict_New (mmgr);
if (!xref->trailer)
goto Fail;
return xref;
Fail:
HPDF_PTRACE((" HPDF_Xref_New failed\n"));
HPDF_Xref_Free (xref);
return NULL;
}
示例4: HPDF_CIDFontDef_New
HPDF_FontDef
HPDF_CIDFontDef_New (HPDF_MMgr mmgr,
char *name,
HPDF_FontDef_InitFunc init_fn)
{
HPDF_FontDef fontdef;
HPDF_CIDFontDefAttr fontdef_attr;
HPDF_PTRACE (" HPDF_CIDFontDef_New\n");
if (!mmgr)
return NULL;
fontdef = HPDF_GetMem (mmgr, sizeof(HPDF_FontDef_Rec));
if (!fontdef)
return NULL;
HPDF_MemSet (fontdef, 0, sizeof(HPDF_FontDef_Rec));
fontdef->sig_bytes = HPDF_FONTDEF_SIG_BYTES;
HPDF_StrCpy (fontdef->base_font, name, fontdef->base_font +
HPDF_LIMIT_MAX_NAME_LEN);
fontdef->mmgr = mmgr;
fontdef->error = mmgr->error;
fontdef->type = HPDF_FONTDEF_TYPE_UNINITIALIZED;
fontdef->free_fn = HPDF_CIDFontDef_FreeFunc;
fontdef->init_fn = init_fn;
fontdef->valid = HPDF_FALSE;
fontdef_attr = HPDF_GetMem (mmgr, sizeof(HPDF_CIDFontDefAttr_Rec));
if (!fontdef_attr) {
HPDF_FreeMem (fontdef->mmgr, fontdef);
return NULL;
}
fontdef->attr = fontdef_attr;
HPDF_MemSet ((HPDF_BYTE *)fontdef_attr, 0,
sizeof(HPDF_CIDFontDefAttr_Rec));
fontdef_attr->widths = HPDF_List_New (mmgr, HPDF_DEF_CHAR_WIDTHS_NUM);
if (!fontdef_attr->widths) {
HPDF_FreeMem (fontdef->mmgr, fontdef);
HPDF_FreeMem (fontdef->mmgr, fontdef_attr);
return NULL;
}
fontdef->missing_width = 500;
fontdef_attr->DW = 1000;
fontdef_attr->DW2[0] = 880;
fontdef_attr->DW2[1] = -1000;
return fontdef;
}
示例5: ReadPngData
static HPDF_STATUS
ReadPngData (HPDF_Dict image,
png_structp png_ptr,
png_infop info_ptr)
{
png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr);
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
png_bytep buf_ptr = HPDF_GetMem (image->mmgr, len);
if (buf_ptr) {
HPDF_UINT i;
for (i = 0; i < (HPDF_UINT)height; i++) {
png_read_rows(png_ptr, (png_byte**)&buf_ptr, NULL, 1);
if (image->error->error_no != HPDF_OK)
break;
if (HPDF_Stream_Write (image->stream, buf_ptr, len) != HPDF_OK)
break;
}
HPDF_FreeMem (image->mmgr, buf_ptr);
}
return image->error->error_no;
}
示例6: Resize
static HPDF_STATUS
Resize (HPDF_List list,
HPDF_UINT count)
{
void **new_obj;
HPDF_PTRACE((" HPDF_List_Resize\n"));
if (list->count >= count) {
if (list->count == count)
return HPDF_OK;
else
return HPDF_INVALID_PARAMETER;
}
new_obj = (void **)HPDF_GetMem (list->mmgr, count * sizeof(void *));
if (!new_obj)
return HPDF_Error_GetCode (list->error);
if (list->obj)
HPDF_MemCpy ((HPDF_BYTE *)new_obj, (HPDF_BYTE *)list->obj,
list->block_siz * sizeof(void *));
list->block_siz = count;
if (list->obj)
HPDF_FreeMem (list->mmgr, list->obj);
list->obj = new_obj;
return HPDF_OK;
}
示例7: HPDF_EncryptDict_New
HPDF_EncryptDict
HPDF_EncryptDict_New (HPDF_MMgr mmgr,
HPDF_Xref xref)
{
HPDF_Encrypt attr;
HPDF_EncryptDict dict;
HPDF_PTRACE((" HPDF_EncryptDict_New\n"));
dict = HPDF_Dict_New (mmgr);
if (!dict)
return NULL;
dict->header.obj_class |= HPDF_OSUBCLASS_ENCRYPT;
dict->free_fn = HPDF_EncryptDict_OnFree;
attr = HPDF_GetMem (dict->mmgr, sizeof(HPDF_Encrypt_Rec));
if (!attr) {
HPDF_Dict_Free (dict);
return NULL;
}
dict->attr = attr;
HPDF_Encrypt_Init (attr);
if (HPDF_Xref_Add (xref, dict) != HPDF_OK)
return NULL;
return dict;
}
示例8: HPDF_String_New
HPDF_String
HPDF_String_New (HPDF_MMgr mmgr,
const char *value,
HPDF_Encoder encoder)
{
HPDF_String obj;
HPDF_PTRACE((" HPDF_String_New\n"));
obj = (HPDF_String)HPDF_GetMem (mmgr, sizeof(HPDF_String_Rec));
if (obj) {
HPDF_MemSet (&obj->header, 0, sizeof(HPDF_Obj_Header));
obj->header.obj_class = HPDF_OCLASS_STRING;
obj->mmgr = mmgr;
obj->error = mmgr->error;
obj->encoder = encoder;
obj->value = NULL;
obj->len = 0;
if (HPDF_String_SetValue (obj, value) != HPDF_OK) {
HPDF_FreeMem (obj->mmgr, obj);
return NULL;
}
}
return obj;
}
示例9: HPDF_String_SetValue
HPDF_STATUS
HPDF_String_SetValue (HPDF_String obj,
const char *value)
{
HPDF_UINT len;
HPDF_STATUS ret = HPDF_OK;
HPDF_PTRACE((" HPDF_String_SetValue\n"));
if (obj->value) {
HPDF_FreeMem (obj->mmgr, obj->value);
obj->len = 0;
}
len = HPDF_StrLen(value, HPDF_LIMIT_MAX_STRING_LEN + 1);
if (len > HPDF_LIMIT_MAX_STRING_LEN)
return HPDF_SetError (obj->error, HPDF_STRING_OUT_OF_RANGE, 0);
obj->value = HPDF_GetMem (obj->mmgr, len + 1);
if (!obj->value)
return HPDF_Error_GetCode (obj->error);
HPDF_StrCpy ((char *)obj->value, value, (char *)obj->value + len);
obj->len = len;
return ret;
}
示例10: HPDF_Binary_New
HPDF_Binary
HPDF_Binary_New (HPDF_MMgr mmgr,
HPDF_BYTE *value,
HPDF_UINT len)
{
HPDF_Binary obj;
obj = HPDF_GetMem (mmgr, sizeof(HPDF_Binary_Rec));
if (obj) {
HPDF_MemSet(&obj->header, 0, sizeof(HPDF_Obj_Header));
obj->header.obj_class = HPDF_OCLASS_BINARY;
obj->mmgr = mmgr;
obj->error = mmgr->error;
obj->value = NULL;
obj->len = 0;
if (HPDF_Binary_SetValue (obj, value, len) != HPDF_OK) {
HPDF_FreeMem (mmgr, obj);
return NULL;
}
}
return obj;
}
示例11: HPDF_CIDFontDef_AddWidth
HPDF_STATUS
HPDF_CIDFontDef_AddWidth (HPDF_FontDef fontdef,
const HPDF_CID_Width *widths)
{
HPDF_CIDFontDefAttr attr = (HPDF_CIDFontDefAttr)fontdef->attr;
HPDF_PTRACE (" HPDF_CIDFontDef_AddWidth\n");
while (widths->cid != 0xFFFF) {
HPDF_CID_Width *w = HPDF_GetMem (fontdef->mmgr,
sizeof (HPDF_CID_Width));
HPDF_STATUS ret;
if (!w)
return fontdef->error->error_no;
w->cid = widths->cid;
w->width = widths->width;
if ((ret = HPDF_List_Add (attr->widths, w)) != HPDF_OK) {
HPDF_FreeMem (fontdef->mmgr, w);
return ret;
}
widths++;
}
return HPDF_OK;
}
示例12: HPDF_Xref_Add
HPDF_STATUS
HPDF_Xref_Add (HPDF_Xref xref,
void *obj)
{
HPDF_XrefEntry entry;
HPDF_Obj_Header *header;
HPDF_PTRACE((" HPDF_Xref_Add\n"));
if (!obj) {
if (HPDF_Error_GetCode (xref->error) == HPDF_OK)
return HPDF_SetError (xref->error, HPDF_INVALID_OBJECT, 0);
else
return HPDF_INVALID_OBJECT;
}
header = (HPDF_Obj_Header *)obj;
if (header->obj_id & HPDF_OTYPE_DIRECT ||
header->obj_id & HPDF_OTYPE_INDIRECT)
return HPDF_SetError(xref->error, HPDF_INVALID_OBJECT, 0);
if (xref->entries->count >= HPDF_LIMIT_MAX_XREF_ELEMENT) {
HPDF_SetError(xref->error, HPDF_XREF_COUNT_ERR, 0);
goto Fail;
}
/* in the following, we have to dispose the object when an error is
* occured.
*/
entry = (HPDF_XrefEntry)HPDF_GetMem (xref->mmgr,
sizeof(HPDF_XrefEntry_Rec));
if (entry == NULL)
goto Fail;
if (HPDF_List_Add(xref->entries, entry) != HPDF_OK) {
HPDF_FreeMem (xref->mmgr, entry);
goto Fail;
}
entry->entry_typ = HPDF_IN_USE_ENTRY;
entry->byte_offset = 0;
entry->gen_no = 0;
entry->obj = obj;
header->obj_id = xref->start_offset + xref->entries->count - 1 +
HPDF_OTYPE_INDIRECT;
header->gen_no = entry->gen_no;
return HPDF_OK;
Fail:
HPDF_Obj_ForceFree(xref->mmgr, obj);
return HPDF_Error_GetCode (xref->error);
}
示例13: HPDF_Page_New
HPDF_Page
HPDF_Page_New (HPDF_MMgr mmgr,
HPDF_Xref xref)
{
HPDF_STATUS ret;
HPDF_PageAttr attr;
HPDF_Page page;
HPDF_PTRACE((" HPDF_Page_New\n"));
page = HPDF_Dict_New (mmgr);
if (!page)
return NULL;
page->header.obj_class |= HPDF_OSUBCLASS_PAGE;
page->free_fn = Page_OnFree;
page->before_write_fn = Page_BeforeWrite;
attr = HPDF_GetMem (page->mmgr, sizeof(HPDF_PageAttr_Rec));
if (!attr) {
HPDF_Dict_Free (page);
return NULL;
}
page->attr = attr;
HPDF_MemSet (attr, 0, sizeof(HPDF_PageAttr_Rec));
attr->gmode = HPDF_GMODE_PAGE_DESCRIPTION;
attr->cur_pos = HPDF_ToPoint (0, 0);
attr->text_pos = HPDF_ToPoint (0, 0);
ret = HPDF_Xref_Add (xref, page);
if (ret != HPDF_OK)
return NULL;
attr->gstate = HPDF_GState_New (page->mmgr, NULL);
attr->contents = HPDF_DictStream_New (page->mmgr, xref);
if (!attr->gstate || !attr->contents)
return NULL;
attr->stream = attr->contents->stream;
attr->xref = xref;
/* add requiered elements */
ret += HPDF_Dict_AddName (page, "Type", "Page");
ret += HPDF_Dict_Add (page, "MediaBox", HPDF_Box_Array_New (page->mmgr,
HPDF_ToBox (0, 0, (HPDF_INT16)(HPDF_DEF_PAGE_WIDTH), (HPDF_INT16)(HPDF_DEF_PAGE_HEIGHT))));
ret += HPDF_Dict_Add (page, "Contents", attr->contents);
ret += AddResource (page);
if (ret != HPDF_OK)
return NULL;
return page;
}
示例14: ReadPngData_Interlaced
static HPDF_STATUS
ReadPngData_Interlaced (HPDF_Dict image,
png_structp png_ptr,
png_infop info_ptr)
{
png_uint_32 len = png_get_rowbytes(png_ptr, info_ptr);
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
png_bytep* row_pointers = HPDF_GetMem (image->mmgr,
height * sizeof (png_bytep));
if (row_pointers) {
HPDF_UINT i;
HPDF_MemSet (row_pointers, 0, height * sizeof (png_bytep));
for (i = 0; i < (HPDF_UINT)height; i++) {
row_pointers[i] = HPDF_GetMem (image->mmgr, len);
if (image->error->error_no != HPDF_OK)
break;
}
if (image->error->error_no == HPDF_OK) {
png_read_image(png_ptr, row_pointers);
if (image->error->error_no == HPDF_OK) { /* add this line */
for (i = 0; i < (HPDF_UINT)height; i++) {
if (HPDF_Stream_Write (image->stream, row_pointers[i], len) !=
HPDF_OK)
break;
}
}
}
/* clean up */
for (i = 0; i < (HPDF_UINT)height; i++) {
HPDF_FreeMem (image->mmgr, row_pointers[i]);
}
HPDF_FreeMem (image->mmgr, row_pointers);
}
return image->error->error_no;
}
示例15: HPDF_NewEx
HPDF_NewEx (HPDF_Error_Handler user_error_fn,
HPDF_Alloc_Func user_alloc_fn,
HPDF_Free_Func user_free_fn,
HPDF_UINT mem_pool_buf_size,
void *user_data)
{
HPDF_Doc pdf;
HPDF_MMgr mmgr;
HPDF_Error_Rec tmp_error;
HPDF_PTRACE ((" HPDF_NewEx\n"));
/* initialize temporary-error object */
HPDF_Error_Init (&tmp_error, user_data);
/* create memory-manager object */
mmgr = HPDF_MMgr_New (&tmp_error, mem_pool_buf_size, user_alloc_fn,
user_free_fn);
if (!mmgr) {
HPDF_CheckError (&tmp_error);
return NULL;
}
/* now create pdf_doc object */
pdf = HPDF_GetMem (mmgr, sizeof (HPDF_Doc_Rec));
if (!pdf) {
HPDF_MMgr_Free (mmgr);
HPDF_CheckError (&tmp_error);
return NULL;
}
HPDF_MemSet (pdf, 0, sizeof (HPDF_Doc_Rec));
pdf->sig_bytes = HPDF_SIG_BYTES;
pdf->mmgr = mmgr;
pdf->pdf_version = HPDF_VER_13;
pdf->compression_mode = HPDF_COMP_NONE;
/* copy the data of temporary-error object to the one which is
included in pdf_doc object */
pdf->error = tmp_error;
/* switch the error-object of memory-manager */
mmgr->error = &pdf->error;
if (HPDF_NewDoc (pdf) != HPDF_OK) {
HPDF_Free (pdf);
HPDF_CheckError (&tmp_error);
return NULL;
}
pdf->error.error_fn = user_error_fn;
return pdf;
}