use libpng native alloc/dealloc
(/valgrind-new-delete2.patch from Jon Burgess)
This commit is contained in:
parent
f4502df850
commit
6fd7d3e488
1 changed files with 4 additions and 15 deletions
|
@ -38,16 +38,6 @@ extern "C"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
//use memory manager for mem allocation in libpng
|
|
||||||
png_voidp malloc_fn(png_structp png_ptr,png_size_t size)
|
|
||||||
{
|
|
||||||
return Object::operator new(size);
|
|
||||||
}
|
|
||||||
void free_fn(png_structp png_ptr, png_voidp ptr)
|
|
||||||
{
|
|
||||||
Object::operator delete(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void save_to_file(std::string const& filename,
|
void save_to_file(std::string const& filename,
|
||||||
std::string const& type,
|
std::string const& type,
|
||||||
|
@ -69,12 +59,11 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
FILE *fp=fopen(filename.c_str(), "wb");
|
FILE *fp=fopen(filename.c_str(), "wb");
|
||||||
if (!fp) return;
|
if (!fp) return;
|
||||||
png_voidp mem_ptr=0;
|
png_voidp error_ptr=0;
|
||||||
png_structp png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
png_structp png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
(png_voidp)mem_ptr,0, 0);
|
error_ptr,0, 0);
|
||||||
|
|
||||||
if (!png_ptr) return;
|
if (!png_ptr) return;
|
||||||
png_set_mem_fn(png_ptr,mem_ptr,malloc_fn,free_fn);
|
|
||||||
|
|
||||||
// switch on optimization only if supported
|
// switch on optimization only if supported
|
||||||
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
|
||||||
|
|
Loading…
Reference in a new issue