| OLD | NEW |
| 1 | 1 |
| 2 /* pngmem.c - stub functions for memory allocation | 2 /* pngmem.c - stub functions for memory allocation |
| 3 * | 3 * |
| 4 * Last changed in libpng 1.2.30 [August 15, 2008] | 4 * Last changed in libpng 1.2.37 [June 4, 2009] |
| 5 * For conditions of distribution and use, see copyright notice in png.h | 5 * For conditions of distribution and use, see copyright notice in png.h |
| 6 * Copyright (c) 1998-2008 Glenn Randers-Pehrson | 6 * Copyright (c) 1998-2009 Glenn Randers-Pehrson |
| 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) | 7 * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
| 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) | 8 * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
| 9 * | 9 * |
| 10 * This file provides a location for all memory allocation. Users who | 10 * This file provides a location for all memory allocation. Users who |
| 11 * need special memory handling are expected to supply replacement | 11 * need special memory handling are expected to supply replacement |
| 12 * functions for png_malloc() and png_free(), and to use | 12 * functions for png_malloc() and png_free(), and to use |
| 13 * png_create_read_struct_2() and png_create_write_struct_2() to | 13 * png_create_read_struct_2() and png_create_write_struct_2() to |
| 14 * identify the replacement functions. | 14 * identify the replacement functions. |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #define PNG_INTERNAL | 17 #define PNG_INTERNAL |
| 18 #include "png.h" | 18 #include "png.h" |
| 19 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) | 19 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) |
| 20 | 20 |
| 21 /* Borland DOS special memory handler */ | 21 /* Borland DOS special memory handler */ |
| 22 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) | 22 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) |
| 23 /* if you change this, be sure to change the one in png.h also */ | 23 /* If you change this, be sure to change the one in png.h also */ |
| 24 | 24 |
| 25 /* Allocate memory for a png_struct. The malloc and memset can be replaced | 25 /* Allocate memory for a png_struct. The malloc and memset can be replaced |
| 26 by a single call to calloc() if this is thought to improve performance. */ | 26 by a single call to calloc() if this is thought to improve performance. */ |
| 27 png_voidp /* PRIVATE */ | 27 png_voidp /* PRIVATE */ |
| 28 png_create_struct(int type) | 28 png_create_struct(int type) |
| 29 { | 29 { |
| 30 #ifdef PNG_USER_MEM_SUPPORTED | 30 #ifdef PNG_USER_MEM_SUPPORTED |
| 31 return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); | 31 return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 /* Alternate version of png_create_struct, for use with user-defined malloc. */ | 34 /* Alternate version of png_create_struct, for use with user-defined malloc. */ |
| 35 png_voidp /* PRIVATE */ | 35 png_voidp /* PRIVATE */ |
| 36 png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) | 36 png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) |
| 37 { | 37 { |
| 38 #endif /* PNG_USER_MEM_SUPPORTED */ | 38 #endif /* PNG_USER_MEM_SUPPORTED */ |
| 39 png_size_t size; | 39 png_size_t size; |
| 40 png_voidp struct_ptr; | 40 png_voidp struct_ptr; |
| 41 | 41 |
| 42 if (type == PNG_STRUCT_INFO) | 42 if (type == PNG_STRUCT_INFO) |
| 43 size = png_sizeof(png_info); | 43 size = png_sizeof(png_info); |
| 44 else if (type == PNG_STRUCT_PNG) | 44 else if (type == PNG_STRUCT_PNG) |
| 45 size = png_sizeof(png_struct); | 45 size = png_sizeof(png_struct); |
| 46 else | 46 else |
| 47 return (png_get_copyright(NULL)); | 47 return (png_get_copyright(NULL)); |
| 48 | 48 |
| 49 #ifdef PNG_USER_MEM_SUPPORTED | 49 #ifdef PNG_USER_MEM_SUPPORTED |
| 50 if (malloc_fn != NULL) | 50 if (malloc_fn != NULL) |
| 51 { | 51 { |
| 52 png_struct dummy_struct; | 52 png_struct dummy_struct; |
| 53 png_structp png_ptr = &dummy_struct; | 53 png_structp png_ptr = &dummy_struct; |
| 54 png_ptr->mem_ptr=mem_ptr; | 54 png_ptr->mem_ptr=mem_ptr; |
| 55 struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); | 55 struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); |
| 56 } | 56 } |
| 57 else | 57 else |
| 58 #endif /* PNG_USER_MEM_SUPPORTED */ | 58 #endif /* PNG_USER_MEM_SUPPORTED */ |
| 59 struct_ptr = (png_voidp)farmalloc(size); | 59 struct_ptr = (png_voidp)farmalloc(size); |
| 60 if (struct_ptr != NULL) | 60 if (struct_ptr != NULL) |
| 61 png_memset(struct_ptr, 0, size); | 61 png_memset(struct_ptr, 0, size); |
| 62 return (struct_ptr); | 62 return (struct_ptr); |
| 63 } | 63 } |
| 64 | 64 |
| 65 /* Free memory allocated by a png_create_struct() call */ | 65 /* Free memory allocated by a png_create_struct() call */ |
| 66 void /* PRIVATE */ | 66 void /* PRIVATE */ |
| 67 png_destroy_struct(png_voidp struct_ptr) | 67 png_destroy_struct(png_voidp struct_ptr) |
| 68 { | 68 { |
| 69 #ifdef PNG_USER_MEM_SUPPORTED | 69 #ifdef PNG_USER_MEM_SUPPORTED |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 png_voidp PNGAPI | 115 png_voidp PNGAPI |
| 116 png_malloc(png_structp png_ptr, png_uint_32 size) | 116 png_malloc(png_structp png_ptr, png_uint_32 size) |
| 117 { | 117 { |
| 118 png_voidp ret; | 118 png_voidp ret; |
| 119 | 119 |
| 120 if (png_ptr == NULL || size == 0) | 120 if (png_ptr == NULL || size == 0) |
| 121 return (NULL); | 121 return (NULL); |
| 122 | 122 |
| 123 #ifdef PNG_USER_MEM_SUPPORTED | 123 #ifdef PNG_USER_MEM_SUPPORTED |
| 124 if (png_ptr->malloc_fn != NULL) | 124 if (png_ptr->malloc_fn != NULL) |
| 125 ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); | 125 ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); |
| 126 else | 126 else |
| 127 ret = (png_malloc_default(png_ptr, size)); | 127 ret = (png_malloc_default(png_ptr, size)); |
| 128 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) | 128 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) |
| 129 png_error(png_ptr, "Out of memory!"); | 129 png_error(png_ptr, "Out of memory!"); |
| 130 return (ret); | 130 return (ret); |
| 131 } | 131 } |
| 132 | 132 |
| 133 png_voidp PNGAPI | 133 png_voidp PNGAPI |
| 134 png_malloc_default(png_structp png_ptr, png_uint_32 size) | 134 png_malloc_default(png_structp png_ptr, png_uint_32 size) |
| 135 { | 135 { |
| 136 png_voidp ret; | 136 png_voidp ret; |
| 137 #endif /* PNG_USER_MEM_SUPPORTED */ | 137 #endif /* PNG_USER_MEM_SUPPORTED */ |
| 138 | 138 |
| 139 if (png_ptr == NULL || size == 0) | 139 if (png_ptr == NULL || size == 0) |
| 140 return (NULL); | 140 return (NULL); |
| 141 | 141 |
| 142 #ifdef PNG_MAX_MALLOC_64K | 142 #ifdef PNG_MAX_MALLOC_64K |
| 143 if (size > (png_uint_32)65536L) | 143 if (size > (png_uint_32)65536L) |
| 144 { | 144 { |
| 145 png_warning(png_ptr, "Cannot Allocate > 64K"); | 145 png_warning(png_ptr, "Cannot Allocate > 64K"); |
| 146 ret = NULL; | 146 ret = NULL; |
| 147 } | 147 } |
| 148 else | 148 else |
| 149 #endif | 149 #endif |
| 150 | 150 |
| 151 if (size != (size_t)size) | 151 if (size != (size_t)size) |
| 152 ret = NULL; | 152 ret = NULL; |
| 153 else if (size == (png_uint_32)65536L) | 153 else if (size == (png_uint_32)65536L) |
| 154 { | 154 { |
| 155 if (png_ptr->offset_table == NULL) | 155 if (png_ptr->offset_table == NULL) |
| 156 { | 156 { |
| 157 /* try to see if we need to do any of this fancy stuff */ | 157 /* Try to see if we need to do any of this fancy stuff */ |
| 158 ret = farmalloc(size); | 158 ret = farmalloc(size); |
| 159 if (ret == NULL || ((png_size_t)ret & 0xffff)) | 159 if (ret == NULL || ((png_size_t)ret & 0xffff)) |
| 160 { | 160 { |
| 161 int num_blocks; | 161 int num_blocks; |
| 162 png_uint_32 total_size; | 162 png_uint_32 total_size; |
| 163 png_bytep table; | 163 png_bytep table; |
| 164 int i; | 164 int i; |
| 165 png_byte huge * hptr; | 165 png_byte huge * hptr; |
| 166 | 166 |
| 167 if (ret != NULL) | 167 if (ret != NULL) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) | 262 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) |
| 263 png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ | 263 png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ |
| 264 else | 264 else |
| 265 png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ | 265 png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ |
| 266 } | 266 } |
| 267 #endif | 267 #endif |
| 268 | 268 |
| 269 return (ret); | 269 return (ret); |
| 270 } | 270 } |
| 271 | 271 |
| 272 /* free a pointer allocated by png_malloc(). In the default | 272 /* Free a pointer allocated by png_malloc(). In the default |
| 273 configuration, png_ptr is not used, but is passed in case it | 273 * configuration, png_ptr is not used, but is passed in case it |
| 274 is needed. If ptr is NULL, return without taking any action. */ | 274 * is needed. If ptr is NULL, return without taking any action. |
| 275 | 275 */ |
| 276 void PNGAPI | 276 void PNGAPI |
| 277 png_free(png_structp png_ptr, png_voidp ptr) | 277 png_free(png_structp png_ptr, png_voidp ptr) |
| 278 { | 278 { |
| 279 if (png_ptr == NULL || ptr == NULL) | 279 if (png_ptr == NULL || ptr == NULL) |
| 280 return; | 280 return; |
| 281 | 281 |
| 282 #ifdef PNG_USER_MEM_SUPPORTED | 282 #ifdef PNG_USER_MEM_SUPPORTED |
| 283 if (png_ptr->free_fn != NULL) | 283 if (png_ptr->free_fn != NULL) |
| 284 { | 284 { |
| 285 (*(png_ptr->free_fn))(png_ptr, ptr); | 285 (*(png_ptr->free_fn))(png_ptr, ptr); |
| 286 return; | 286 return; |
| 287 } | 287 } |
| 288 else png_free_default(png_ptr, ptr); | 288 else |
| 289 png_free_default(png_ptr, ptr); |
| 289 } | 290 } |
| 290 | 291 |
| 291 void PNGAPI | 292 void PNGAPI |
| 292 png_free_default(png_structp png_ptr, png_voidp ptr) | 293 png_free_default(png_structp png_ptr, png_voidp ptr) |
| 293 { | 294 { |
| 294 #endif /* PNG_USER_MEM_SUPPORTED */ | 295 #endif /* PNG_USER_MEM_SUPPORTED */ |
| 295 | 296 |
| 296 if (png_ptr == NULL || ptr == NULL) return; | 297 if (png_ptr == NULL || ptr == NULL) |
| 298 return; |
| 297 | 299 |
| 298 if (png_ptr->offset_table != NULL) | 300 if (png_ptr->offset_table != NULL) |
| 299 { | 301 { |
| 300 int i; | 302 int i; |
| 301 | 303 |
| 302 for (i = 0; i < png_ptr->offset_table_count; i++) | 304 for (i = 0; i < png_ptr->offset_table_count; i++) |
| 303 { | 305 { |
| 304 if (ptr == png_ptr->offset_table_ptr[i]) | 306 if (ptr == png_ptr->offset_table_ptr[i]) |
| 305 { | 307 { |
| 306 ptr = NULL; | 308 ptr = NULL; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 # if defined(_MSC_VER) && defined(MAXSEG_64K) | 415 # if defined(_MSC_VER) && defined(MAXSEG_64K) |
| 414 hfree(struct_ptr); | 416 hfree(struct_ptr); |
| 415 # else | 417 # else |
| 416 free(struct_ptr); | 418 free(struct_ptr); |
| 417 # endif | 419 # endif |
| 418 #endif | 420 #endif |
| 419 } | 421 } |
| 420 } | 422 } |
| 421 | 423 |
| 422 /* Allocate memory. For reasonable files, size should never exceed | 424 /* Allocate memory. For reasonable files, size should never exceed |
| 423 64K. However, zlib may allocate more then 64K if you don't tell | 425 * 64K. However, zlib may allocate more then 64K if you don't tell |
| 424 it not to. See zconf.h and png.h for more information. zlib does | 426 * it not to. See zconf.h and png.h for more information. zlib does |
| 425 need to allocate exactly 64K, so whatever you call here must | 427 * need to allocate exactly 64K, so whatever you call here must |
| 426 have the ability to do that. */ | 428 * have the ability to do that. |
| 429 */ |
| 427 | 430 |
| 428 | 431 |
| 429 png_voidp PNGAPI | 432 png_voidp PNGAPI |
| 430 png_malloc(png_structp png_ptr, png_uint_32 size) | 433 png_malloc(png_structp png_ptr, png_uint_32 size) |
| 431 { | 434 { |
| 432 png_voidp ret; | 435 png_voidp ret; |
| 433 | 436 |
| 434 #ifdef PNG_USER_MEM_SUPPORTED | 437 #ifdef PNG_USER_MEM_SUPPORTED |
| 435 if (png_ptr == NULL || size == 0) | 438 if (png_ptr == NULL || size == 0) |
| 436 return (NULL); | 439 return (NULL); |
| 437 | 440 |
| 438 if (png_ptr->malloc_fn != NULL) | 441 if (png_ptr->malloc_fn != NULL) |
| 439 ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); | 442 ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); |
| 440 else | 443 else |
| 441 ret = (png_malloc_default(png_ptr, size)); | 444 ret = (png_malloc_default(png_ptr, size)); |
| 442 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) | 445 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) |
| 443 png_error(png_ptr, "Out of Memory!"); | 446 png_error(png_ptr, "Out of Memory!"); |
| 444 return (ret); | 447 return (ret); |
| 445 } | 448 } |
| 446 | 449 |
| 447 png_voidp PNGAPI | 450 png_voidp PNGAPI |
| 448 png_malloc_default(png_structp png_ptr, png_uint_32 size) | 451 png_malloc_default(png_structp png_ptr, png_uint_32 size) |
| 449 { | 452 { |
| 450 png_voidp ret; | 453 png_voidp ret; |
| 451 #endif /* PNG_USER_MEM_SUPPORTED */ | 454 #endif /* PNG_USER_MEM_SUPPORTED */ |
| 452 | 455 |
| 453 if (png_ptr == NULL || size == 0) | 456 if (png_ptr == NULL || size == 0) |
| 454 return (NULL); | 457 return (NULL); |
| 455 | 458 |
| 456 #ifdef PNG_MAX_MALLOC_64K | 459 #ifdef PNG_MAX_MALLOC_64K |
| 457 if (size > (png_uint_32)65536L) | 460 if (size > (png_uint_32)65536L) |
| 458 { | 461 { |
| 459 #ifndef PNG_USER_MEM_SUPPORTED | 462 #ifndef PNG_USER_MEM_SUPPORTED |
| 460 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) | 463 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) |
| 461 png_error(png_ptr, "Cannot Allocate > 64K"); | 464 png_error(png_ptr, "Cannot Allocate > 64K"); |
| 462 else | 465 else |
| 463 #endif | 466 #endif |
| 464 return NULL; | 467 return NULL; |
| 465 } | 468 } |
| 466 #endif | 469 #endif |
| 467 | 470 |
| 468 /* Check for overflow */ | 471 /* Check for overflow */ |
| 469 #if defined(__TURBOC__) && !defined(__FLAT__) | 472 #if defined(__TURBOC__) && !defined(__FLAT__) |
| 470 if (size != (unsigned long)size) | 473 if (size != (unsigned long)size) |
| 471 ret = NULL; | 474 ret = NULL; |
| 472 else | 475 else |
| 473 ret = farmalloc(size); | 476 ret = farmalloc(size); |
| 474 #else | 477 #else |
| 475 # if defined(_MSC_VER) && defined(MAXSEG_64K) | 478 # if defined(_MSC_VER) && defined(MAXSEG_64K) |
| 476 if (size != (unsigned long)size) | 479 if (size != (unsigned long)size) |
| 477 ret = NULL; | 480 ret = NULL; |
| 478 else | 481 else |
| 479 ret = halloc(size, 1); | 482 ret = halloc(size, 1); |
| 480 # else | 483 # else |
| 481 if (size != (size_t)size) | 484 if (size != (size_t)size) |
| 482 ret = NULL; | 485 ret = NULL; |
| 483 else | 486 else |
| 484 ret = malloc((size_t)size); | 487 ret = malloc((size_t)size); |
| 485 # endif | 488 # endif |
| 486 #endif | 489 #endif |
| 487 | 490 |
| 488 #ifndef PNG_USER_MEM_SUPPORTED | 491 #ifndef PNG_USER_MEM_SUPPORTED |
| 489 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) | 492 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) |
| 490 png_error(png_ptr, "Out of Memory"); | 493 png_error(png_ptr, "Out of Memory"); |
| 491 #endif | 494 #endif |
| 492 | 495 |
| 493 return (ret); | 496 return (ret); |
| 494 } | 497 } |
| 495 | 498 |
| 496 /* Free a pointer allocated by png_malloc(). If ptr is NULL, return | 499 /* Free a pointer allocated by png_malloc(). If ptr is NULL, return |
| 497 without taking any action. */ | 500 * without taking any action. |
| 501 */ |
| 498 void PNGAPI | 502 void PNGAPI |
| 499 png_free(png_structp png_ptr, png_voidp ptr) | 503 png_free(png_structp png_ptr, png_voidp ptr) |
| 500 { | 504 { |
| 501 if (png_ptr == NULL || ptr == NULL) | 505 if (png_ptr == NULL || ptr == NULL) |
| 502 return; | 506 return; |
| 503 | 507 |
| 504 #ifdef PNG_USER_MEM_SUPPORTED | 508 #ifdef PNG_USER_MEM_SUPPORTED |
| 505 if (png_ptr->free_fn != NULL) | 509 if (png_ptr->free_fn != NULL) |
| 506 { | 510 { |
| 507 (*(png_ptr->free_fn))(png_ptr, ptr); | 511 (*(png_ptr->free_fn))(png_ptr, ptr); |
| 508 return; | 512 return; |
| 509 } | 513 } |
| 510 else png_free_default(png_ptr, ptr); | 514 else |
| 515 png_free_default(png_ptr, ptr); |
| 511 } | 516 } |
| 512 void PNGAPI | 517 void PNGAPI |
| 513 png_free_default(png_structp png_ptr, png_voidp ptr) | 518 png_free_default(png_structp png_ptr, png_voidp ptr) |
| 514 { | 519 { |
| 515 if (png_ptr == NULL || ptr == NULL) | 520 if (png_ptr == NULL || ptr == NULL) |
| 516 return; | 521 return; |
| 517 | 522 |
| 518 #endif /* PNG_USER_MEM_SUPPORTED */ | 523 #endif /* PNG_USER_MEM_SUPPORTED */ |
| 519 | 524 |
| 520 #if defined(__TURBOC__) && !defined(__FLAT__) | 525 #if defined(__TURBOC__) && !defined(__FLAT__) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 536 /* This function was added at libpng version 1.2.3. The png_malloc_warn() | 541 /* This function was added at libpng version 1.2.3. The png_malloc_warn() |
| 537 * function will set up png_malloc() to issue a png_warning and return NULL | 542 * function will set up png_malloc() to issue a png_warning and return NULL |
| 538 * instead of issuing a png_error, if it fails to allocate the requested | 543 * instead of issuing a png_error, if it fails to allocate the requested |
| 539 * memory. | 544 * memory. |
| 540 */ | 545 */ |
| 541 png_voidp PNGAPI | 546 png_voidp PNGAPI |
| 542 png_malloc_warn(png_structp png_ptr, png_uint_32 size) | 547 png_malloc_warn(png_structp png_ptr, png_uint_32 size) |
| 543 { | 548 { |
| 544 png_voidp ptr; | 549 png_voidp ptr; |
| 545 png_uint_32 save_flags; | 550 png_uint_32 save_flags; |
| 546 if (png_ptr == NULL) return (NULL); | 551 if (png_ptr == NULL) |
| 552 return (NULL); |
| 547 | 553 |
| 548 save_flags = png_ptr->flags; | 554 save_flags = png_ptr->flags; |
| 549 png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; | 555 png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; |
| 550 ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); | 556 ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); |
| 551 png_ptr->flags=save_flags; | 557 png_ptr->flags=save_flags; |
| 552 return(ptr); | 558 return(ptr); |
| 553 } | 559 } |
| 554 #endif | 560 #endif |
| 555 | 561 |
| 556 png_voidp PNGAPI | 562 png_voidp PNGAPI |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 602 } |
| 597 } | 603 } |
| 598 | 604 |
| 599 /* This function returns a pointer to the mem_ptr associated with the user | 605 /* This function returns a pointer to the mem_ptr associated with the user |
| 600 * functions. The application should free any memory associated with this | 606 * functions. The application should free any memory associated with this |
| 601 * pointer before png_write_destroy and png_read_destroy are called. | 607 * pointer before png_write_destroy and png_read_destroy are called. |
| 602 */ | 608 */ |
| 603 png_voidp PNGAPI | 609 png_voidp PNGAPI |
| 604 png_get_mem_ptr(png_structp png_ptr) | 610 png_get_mem_ptr(png_structp png_ptr) |
| 605 { | 611 { |
| 606 if (png_ptr == NULL) return (NULL); | 612 if (png_ptr == NULL) |
| 613 return (NULL); |
| 607 return ((png_voidp)png_ptr->mem_ptr); | 614 return ((png_voidp)png_ptr->mem_ptr); |
| 608 } | 615 } |
| 609 #endif /* PNG_USER_MEM_SUPPORTED */ | 616 #endif /* PNG_USER_MEM_SUPPORTED */ |
| 610 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ | 617 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ |
| OLD | NEW |