本文整理汇总了C++中png_memset函数的典型用法代码示例。如果您正苦于以下问题:C++ png_memset函数的具体用法?C++ png_memset怎么用?C++ png_memset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了png_memset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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));
}
示例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
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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);
}