本文整理汇总了C++中png_memset函数的典型用法代码示例。如果您正苦于以下问题:C++ png_memset函数的具体用法?C++ png_memset怎么用?C++ png_memset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了png_memset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: png_create_struct
/* Allocate memory for a png_struct or a png_info. The malloc and
* memset can be replaced by a single call to calloc() if this is thought
* to improve performance noticably.
*/
png_voidp
png_create_struct(uInt type)
{
size_t size;
png_voidp struct_ptr;
if (type == PNG_STRUCT_INFO)
size = sizeof(png_info);
else if (type == PNG_STRUCT_PNG)
size = sizeof(png_struct);
else
return (png_voidp)NULL;
#if defined(__TURBOC__) && !defined(__FLAT__)
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
if ((struct_ptr = (png_voidp)halloc(size,1)) != NULL)
# else
if ((struct_ptr = (png_voidp)malloc(size)) != NULL)
# endif
#endif
{
png_memset(struct_ptr, 0, size);
}
return (struct_ptr);
}
开发者ID:deepmatrix,项目名称:blaxxun-cc3d,代码行数:32,代码来源:pngmem.c
示例2: png_info_init
/* Initialize the info structure. This is now an internal function (0.89)
* and applications using it are urged to use png_create_info_struct()
* instead.
*/
void
png_info_init(png_infop info_ptr)
{
png_debug(1, "in png_info_init\n");
/* set everything to 0 */
png_memset(info_ptr, 0, sizeof (png_info));
}
开发者ID:svn2github,项目名称:htmldoc,代码行数:11,代码来源:png.c
示例3: png_write_init
/* Initialize png_ptr structure, and allocate any memory needed */
void
png_write_init(png_structp png_ptr)
{
jmp_buf tmp_jmp; /* to save current jump buffer */
png_debug(1, "in png_write_init\n");
/* save jump buffer and error functions */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
/* reset all variables to 0 */
png_memset(png_ptr, 0, sizeof (png_struct));
/* restore jump buffer */
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
/* initialize zbuf - compression buffer */
png_ptr->zbuf_size = PNG_ZBUF_SIZE;
png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
(png_uint_32)png_ptr->zbuf_size);
png_set_write_fn(png_ptr, NULL, NULL, NULL);
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_set_filter_heuristics(png_ptr, PNG_FILTER_HEURISTIC_DEFAULT,
1, NULL, NULL);
#endif
}
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:27,代码来源:pngwrite.c
示例4: png_create_struct_2
/* Alternate version of png_create_struct, for use with user-defined malloc. */
png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
{
#endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size;
png_voidp struct_ptr;
if (type == PNG_STRUCT_INFO)
size = png_sizeof(png_info);
else if (type == PNG_STRUCT_PNG)
size = png_sizeof(png_struct);
else
return (png_get_copyright(NULL));
#ifdef PNG_USER_MEM_SUPPORTED
if (malloc_fn != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
}
else
#endif /* PNG_USER_MEM_SUPPORTED */
struct_ptr = (png_voidp)farmalloc(size);
if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size);
return (struct_ptr);
}
开发者ID:RasterCode,项目名称:wke,代码行数:30,代码来源:pngmem.c
示例5: png_debug_malloc
png_voidp
png_debug_malloc(png_structp png_ptr, png_uint_32 size)
{
/* png_malloc has already tested for NULL; png_create_struct calls
png_debug_malloc directly, with png_ptr == NULL which is OK */
if (size == 0)
return (NULL);
/* This calls the library allocator twice, once to get the requested
buffer and once to get a new free list entry. */
{
memory_infop pinfo = (memory_infop)png_malloc_default(png_ptr,
(png_uint_32)sizeof *pinfo);
pinfo->size = size;
current_allocation += size;
total_allocation += size;
num_allocations ++;
if (current_allocation > maximum_allocation)
maximum_allocation = current_allocation;
pinfo->pointer = (png_voidp)png_malloc_default(png_ptr, size);
pinfo->next = pinformation;
pinformation = pinfo;
/* Make sure the caller isn't assuming zeroed memory. */
png_memset(pinfo->pointer, 0xdd, pinfo->size);
#if PNG_DEBUG
if(verbose)
printf("png_malloc %lu bytes at %x\n",size,pinfo->pointer);
#endif
assert(pinfo->size != 12345678);
return (png_voidp)(pinfo->pointer);
}
}
开发者ID:kimsama,项目名称:minimangalore,代码行数:34,代码来源:pngtest.c
示例6: png_zalloc
voidpf PNGAPI
#else
voidpf /* PRIVATE */
#endif
png_zalloc(voidpf png_ptr, uInt items, uInt size)
{
png_voidp ptr;
png_structp p;
png_uint_32 save_flags;
png_uint_32 num_bytes;
if (png_ptr == NULL)
return (NULL);
p=(png_structp)png_ptr;
save_flags=p->flags;
if (items > PNG_UINT_32_MAX/size)
{
png_warning (p, "Potential overflow in png_zalloc()");
return (NULL);
}
num_bytes = (png_uint_32)items * size;
p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
p->flags=save_flags;
#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO)
if (ptr == NULL)
return ((voidpf)ptr);
if (num_bytes > (png_uint_32)0x8000L)
{
png_memset(ptr, 0, (png_size_t)0x8000L);
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
}
else
{
png_memset(ptr, 0, (png_size_t)num_bytes);
}
#endif
return ((voidpf)ptr);
}
开发者ID:A2-Collaboration,项目名称:root,代码行数:45,代码来源:png.c
示例7: png_zalloc
/* Function to allocate memory for zlib. */
voidpf
png_zalloc(voidpf png_ptr, uInt items, uInt size)
{
png_uint_32 num_bytes = (png_uint_32)items * size;
png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
if (num_bytes > (png_uint_32)0x8000L)
{
png_memset(ptr, 0, (png_size_t)0x8000L);
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
}
else
{
png_memset(ptr, 0, (png_size_t)num_bytes);
}
return ((voidpf)ptr);
}
开发者ID:RaymondLiao,项目名称:elektronika,代码行数:19,代码来源:png.c
示例8: png_calloc
png_voidp PNGAPI
png_calloc(png_structp png_ptr, png_alloc_size_t size)
{
png_voidp ret;
ret = (png_malloc(png_ptr, size));
if (ret != NULL)
png_memset(ret,0,(png_size_t)size);
return (ret);
}
开发者ID:Asvarox,项目名称:Unvanquished,代码行数:10,代码来源:pngmem.c
示例9: png_calloc
png_voidp /* PRIVATE */
png_calloc(png_structp png_ptr, png_uint_32 size)
{
png_voidp ret;
ret = (png_malloc(png_ptr, size));
if (ret != NULL)
png_memset(ret,0,(png_size_t)size);
return (ret);
}
开发者ID:AbdelghaniDr,项目名称:VisualizationLibrary,代码行数:10,代码来源:pngmem.c
示例10: png_write_destroy
/* Free any memory used in png_ptr struct (old method) */
void
png_write_destroy(png_structp png_ptr)
{
jmp_buf tmp_jmp; /* save jump buffer */
png_error_ptr error_fn;
png_error_ptr warning_fn;
png_voidp error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_free_ptr free_fn;
#endif
png_debug(1, "in png_write_destroy\n");
/* free any memory zlib uses */
deflateEnd(&png_ptr->zstream);
/* free our memory. png_free checks NULL for us. */
png_free(png_ptr, png_ptr->zbuf);
png_free(png_ptr, png_ptr->row_buf);
png_free(png_ptr, png_ptr->prev_row);
png_free(png_ptr, png_ptr->sub_row);
png_free(png_ptr, png_ptr->up_row);
png_free(png_ptr, png_ptr->avg_row);
png_free(png_ptr, png_ptr->paeth_row);
#if defined(PNG_TIME_RFC1123_SUPPORTED)
png_free(png_ptr, png_ptr->time_buffer);
#endif /* PNG_TIME_RFC1123_SUPPORTED */
#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
png_free(png_ptr, png_ptr->prev_filters);
png_free(png_ptr, png_ptr->filter_weights);
png_free(png_ptr, png_ptr->inv_filter_weights);
png_free(png_ptr, png_ptr->filter_costs);
png_free(png_ptr, png_ptr->inv_filter_costs);
#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
/* reset structure */
png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf));
error_fn = png_ptr->error_fn;
warning_fn = png_ptr->warning_fn;
error_ptr = png_ptr->error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
free_fn = png_ptr->free_fn;
#endif
png_memset(png_ptr, 0, sizeof (png_struct));
png_ptr->error_fn = error_fn;
png_ptr->warning_fn = warning_fn;
png_ptr->error_ptr = error_ptr;
#ifdef PNG_USER_MEM_SUPPORTED
png_ptr->free_fn = free_fn;
#endif
png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf));
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:56,代码来源:pngwrite.c
示例11: calloc
/* Allocate memory for a png_struct or a png_info. The malloc and
memset can be replaced by a single call to calloc() if this is thought
to improve performance noticably. */
png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) {
#endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size;
png_voidp struct_ptr;
if (type == PNG_STRUCT_INFO) {
size = png_sizeof(png_info);
} else if (type == PNG_STRUCT_PNG) {
size = png_sizeof(png_struct);
} else {
return (NULL);
}
#ifdef PNG_USER_MEM_SUPPORTED
if (malloc_fn != NULL) {
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr = mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, size);
if (struct_ptr != NULL) {
png_memset(struct_ptr, 0, size);
}
return (struct_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__)
struct_ptr = (png_voidp)farmalloc(size);
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
struct_ptr = (png_voidp)halloc(size, 1);
# else
struct_ptr = (png_voidp)malloc(size);
# endif
#endif
if (struct_ptr != NULL) {
png_memset(struct_ptr, 0, size);
}
return (struct_ptr);
}
开发者ID:353,项目名称:viewercv,代码行数:45,代码来源:pngmem.c
示例12: png_zalloc
/* Function to allocate memory for zlib and clear it to 0. */
voidpf /* PRIVATE */
png_zalloc(voidpf png_ptr, uInt items, uInt size)
{
png_uint_32 num_bytes = (png_uint_32)items * size;
png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
#ifndef PNG_NO_ZALLOC_ZERO
if (num_bytes > (png_uint_32)0x8000L)
{
png_memset(ptr, 0, (png_size_t)0x8000L);
png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
(png_size_t)(num_bytes - (png_uint_32)0x8000L));
}
else
{
png_memset(ptr, 0, (png_size_t)num_bytes);
}
#endif
return ((voidpf)ptr);
}
开发者ID:jstavr,项目名称:Architecture-Relation-Evaluator,代码行数:21,代码来源:png.c
示例13: pngx_malloc_rows_extended
png_bytepp PNGAPI
pngx_malloc_rows_extended(png_structp png_ptr, png_infop info_ptr,
pngx_alloc_size_t min_row_size, int filler)
{
pngx_alloc_size_t row_size;
png_bytep row;
png_bytepp rows;
png_uint_32 height, i;
/* Calculate the row size. */
row_size = png_get_rowbytes(png_ptr, info_ptr);
if (row_size == 0)
return NULL;
if (row_size < min_row_size)
row_size = min_row_size;
/* Deallocate the currently-existing rows. */
png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
/* Allocate memory for the row index. */
height = png_get_image_height(png_ptr, info_ptr);
if (height > (pngx_alloc_size_t)(-1) / sizeof(png_bytep))
{
png_warning(png_ptr, "Image height is too large");
return NULL;
}
rows = (png_bytepp)png_malloc(png_ptr,
(pngx_alloc_size_t)(height * sizeof(png_bytep)));
if (rows == NULL)
return NULL;
/* Allocate memory for each row. */
for (i = 0; i < height; ++i)
{
row = (png_bytep)png_malloc(png_ptr, row_size);
if (row == NULL) /* out of memory? */
{
/* Release the memory allocated up to the point of failure. */
while (i > 0)
png_free(png_ptr, rows[--i]);
png_free(png_ptr, rows);
return NULL;
}
if (filler >= 0)
png_memset(row, filler, row_size);
rows[i] = row;
}
/* Set the row pointers. */
png_set_rows(png_ptr, info_ptr, rows);
return rows;
}
开发者ID:juntalis,项目名称:PyOptiPng,代码行数:52,代码来源:pngxmem.c
示例14: png_memset_check
png_voidp PNGAPI
png_memset_check (png_structp png_ptr, png_voidp s1, int value,
png_uint_32 length)
{
png_size_t size;
size = (png_size_t)length;
if ((png_uint_32)size != length)
png_error(png_ptr, "Overflow in png_memset_check.");
return (png_memset (s1, value, size));
}
开发者ID:AbdelghaniDr,项目名称:VisualizationLibrary,代码行数:13,代码来源:pngmem.c
示例15: calloc
/* Allocate memory for a png_struct or a png_info. The malloc and
memset can be replaced by a single call to calloc() if this is thought
to improve performance noticably.*/
png_voidp
png_create_struct_2(int type, png_malloc_ptr malloc_fn)
{
#endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size;
png_voidp struct_ptr;
if (type == PNG_STRUCT_INFO)
size = sizeof(png_info);
else if (type == PNG_STRUCT_PNG)
size = sizeof(png_struct);
else
return ((png_voidp)NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL)
{
if ((struct_ptr = (*(malloc_fn))(NULL, size)) != NULL)
png_memset(struct_ptr, 0, size);
return (struct_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
#if defined(__TURBOC__) && !defined(__FLAT__)
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
#else
# if defined(_MSC_VER) && defined(MAXSEG_64K)
if ((struct_ptr = (png_voidp)halloc(size,1)) != NULL)
# else
if ((struct_ptr = (png_voidp)malloc(size)) != NULL)
# endif
#endif
{
png_memset(struct_ptr, 0, size);
}
return (struct_ptr);
}
开发者ID:pinchyCZN,项目名称:deepness,代码行数:41,代码来源:PNGMEM.C
示例16: calloc
/* Allocate memory for a png_struct or a png_info. The malloc and
memset can be replaced by a single call to calloc() if this is thought
to improve performance noticably. */
png_voidp /* PRIVATE */
png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
{
#endif /* PNG_USER_MEM_SUPPORTED */
png_size_t size;
png_voidp struct_ptr;
if (type == PNG_STRUCT_INFO)
size = png_sizeof(png_info);
else if (type == PNG_STRUCT_PNG)
size = png_sizeof(png_struct);
else
return (NULL);
#ifdef PNG_USER_MEM_SUPPORTED
if(malloc_fn != NULL)
{
png_struct dummy_struct;
png_structp png_ptr = &dummy_struct;
png_ptr->mem_ptr=mem_ptr;
struct_ptr = (*(malloc_fn))(png_ptr, size);
if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size);
return (struct_ptr);
}
#endif /* PNG_USER_MEM_SUPPORTED */
if (g_png_default_malloc_ptr)
struct_ptr = (png_voidp)(*g_png_default_malloc_ptr)(size);
else
struct_ptr = (png_voidp)malloc(size);
if (struct_ptr != NULL)
png_memset(struct_ptr, 0, size);
return (struct_ptr);
}
开发者ID:GRGSIBERIA,项目名称:EAWebKit,代码行数:40,代码来源:pngmem.c
示例17: png_debug_free
/* Free a pointer. It is removed from the list at the same time. */
void
png_debug_free(png_structp png_ptr, png_voidp ptr)
{
if (png_ptr == NULL)
fprintf(STDERR, "NULL pointer to png_debug_free.\n");
if (ptr == 0)
{
#if 0 /* This happens all the time. */
fprintf(STDERR, "WARNING: freeing NULL pointer\n");
#endif
return;
}
/* Unlink the element from the list. */
{
memory_infop FAR *ppinfo = &pinformation;
for (;;)
{
memory_infop pinfo = *ppinfo;
if (pinfo->pointer == ptr)
{
*ppinfo = pinfo->next;
current_allocation -= pinfo->size;
if (current_allocation < 0)
fprintf(STDERR, "Duplicate free of memory\n");
/* We must free the list element too, but first kill
the memory that is to be freed. */
png_memset(ptr, 0x55, pinfo->size);
png_free_default(png_ptr, pinfo);
pinfo=NULL;
break;
}
if (pinfo->next == NULL)
{
fprintf(STDERR, "Pointer %x not found\n", (unsigned int)ptr);
break;
}
ppinfo = &pinfo->next;
}
}
/* Finally free the data. */
#if PNG_DEBUG
if(verbose)
printf("Freeing %x\n",ptr);
#endif
png_free_default(png_ptr, ptr);
ptr=NULL;
}
开发者ID:Starlink,项目名称:tkimg,代码行数:50,代码来源:pngtest.c
示例18: png_info_init_3
void PNGAPI
png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
{
png_infop info_ptr = *ptr_ptr;
png_debug(1, "in png_info_init_3\n");
if (png_sizeof(png_info) > png_info_struct_size) {
png_destroy_struct(info_ptr);
info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
*ptr_ptr = info_ptr;
}
/* set everything to 0 */
png_memset(info_ptr, 0, png_sizeof(png_info));
}
开发者ID:cafeinecake,项目名称:hge2,代码行数:16,代码来源:png.c
示例19: png_debug_malloc
png_voidp
png_debug_malloc(png_structp png_ptr, png_uint_32 size)
{
/* png_malloc has already tested for NULL; png_create_struct calls
* png_debug_malloc directly, with png_ptr == NULL which is OK
*/
if (size == 0)
return (NULL);
/* This calls the library allocator twice, once to get the requested
buffer and once to get a new free list entry. */
{
/* Disable malloc_fn and free_fn */
memory_infop pinfo;
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
pinfo = (memory_infop)png_malloc(png_ptr,
(png_uint_32)png_sizeof(*pinfo));
pinfo->size = size;
current_allocation += size;
total_allocation += size;
num_allocations ++;
if (current_allocation > maximum_allocation)
maximum_allocation = current_allocation;
pinfo->pointer = (png_voidp)png_malloc(png_ptr, size);
/* Restore malloc_fn and free_fn */
png_set_mem_fn(png_ptr,
png_voidp_NULL, (png_malloc_ptr)png_debug_malloc,
(png_free_ptr)png_debug_free);
if (size != 0 && pinfo->pointer == NULL)
{
current_allocation -= size;
total_allocation -= size;
png_error(png_ptr,
"out of memory in pngtest->png_debug_malloc.");
}
pinfo->next = pinformation;
pinformation = pinfo;
/* Make sure the caller isn't assuming zeroed memory. */
png_memset(pinfo->pointer, 0xdd, pinfo->size);
if (verbose)
printf("png_malloc %lu bytes at %x\n", (unsigned long)size,
pinfo->pointer);
return (png_voidp)(pinfo->pointer);
}
}
开发者ID:0ryuO,项目名称:dolphin-avsync,代码行数:47,代码来源:pngtest.c
示例20: png_create_struct
png_voidp
png_create_struct(int type)
{
png_size_t size;
png_voidp struct_ptr;
if (type == PNG_STRUCT_INFO)
size = sizeof(png_info);
else if (type == PNG_STRUCT_PNG)
size = sizeof(png_struct);
else
return ((png_voidp)NULL);
if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL)
{
png_memset(struct_ptr, 0, size);
}
return (struct_ptr);
}
开发者ID:AMDmi3,项目名称:analog,代码行数:19,代码来源:pngmem.c
注:本文中的png_memset函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论