Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: third_party/libpng/pngmem.c

Issue 15041: Update libpng to 1.2.33. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/libpng/pngget.c ('k') | third_party/libpng/pngpread.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.27 [April 29, 2008] 4 * Last changed in libpng 1.2.30 [August 15, 2008]
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-2008 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
20 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) 19 #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
21 20
22 /* Borland DOS special memory handler */ 21 /* Borland DOS special memory handler */
23 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) 22 #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
24 /* 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 */
25 24
26 /* 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
27 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. */
28 png_voidp /* PRIVATE */ 27 png_voidp /* PRIVATE */
29 png_create_struct(int type) 28 png_create_struct(int type)
(...skipping 11 matching lines...) Expand all
41 png_voidp struct_ptr; 40 png_voidp struct_ptr;
42 41
43 if (type == PNG_STRUCT_INFO) 42 if (type == PNG_STRUCT_INFO)
44 size = png_sizeof(png_info); 43 size = png_sizeof(png_info);
45 else if (type == PNG_STRUCT_PNG) 44 else if (type == PNG_STRUCT_PNG)
46 size = png_sizeof(png_struct); 45 size = png_sizeof(png_struct);
47 else 46 else
48 return (png_get_copyright(NULL)); 47 return (png_get_copyright(NULL));
49 48
50 #ifdef PNG_USER_MEM_SUPPORTED 49 #ifdef PNG_USER_MEM_SUPPORTED
51 if(malloc_fn != NULL) 50 if (malloc_fn != NULL)
52 { 51 {
53 png_struct dummy_struct; 52 png_struct dummy_struct;
54 png_structp png_ptr = &dummy_struct; 53 png_structp png_ptr = &dummy_struct;
55 png_ptr->mem_ptr=mem_ptr; 54 png_ptr->mem_ptr=mem_ptr;
56 struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); 55 struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
57 } 56 }
58 else 57 else
59 #endif /* PNG_USER_MEM_SUPPORTED */ 58 #endif /* PNG_USER_MEM_SUPPORTED */
60 struct_ptr = (png_voidp)farmalloc(size); 59 struct_ptr = (png_voidp)farmalloc(size);
61 if (struct_ptr != NULL) 60 if (struct_ptr != NULL)
(...skipping 11 matching lines...) Expand all
73 72
74 /* Free memory allocated by a png_create_struct() call */ 73 /* Free memory allocated by a png_create_struct() call */
75 void /* PRIVATE */ 74 void /* PRIVATE */
76 png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, 75 png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
77 png_voidp mem_ptr) 76 png_voidp mem_ptr)
78 { 77 {
79 #endif 78 #endif
80 if (struct_ptr != NULL) 79 if (struct_ptr != NULL)
81 { 80 {
82 #ifdef PNG_USER_MEM_SUPPORTED 81 #ifdef PNG_USER_MEM_SUPPORTED
83 if(free_fn != NULL) 82 if (free_fn != NULL)
84 { 83 {
85 png_struct dummy_struct; 84 png_struct dummy_struct;
86 png_structp png_ptr = &dummy_struct; 85 png_structp png_ptr = &dummy_struct;
87 png_ptr->mem_ptr=mem_ptr; 86 png_ptr->mem_ptr=mem_ptr;
88 (*(free_fn))(png_ptr, struct_ptr); 87 (*(free_fn))(png_ptr, struct_ptr);
89 return; 88 return;
90 } 89 }
91 #endif /* PNG_USER_MEM_SUPPORTED */ 90 #endif /* PNG_USER_MEM_SUPPORTED */
92 farfree (struct_ptr); 91 farfree (struct_ptr);
93 } 92 }
(...skipping 21 matching lines...) Expand all
115 114
116 png_voidp PNGAPI 115 png_voidp PNGAPI
117 png_malloc(png_structp png_ptr, png_uint_32 size) 116 png_malloc(png_structp png_ptr, png_uint_32 size)
118 { 117 {
119 png_voidp ret; 118 png_voidp ret;
120 119
121 if (png_ptr == NULL || size == 0) 120 if (png_ptr == NULL || size == 0)
122 return (NULL); 121 return (NULL);
123 122
124 #ifdef PNG_USER_MEM_SUPPORTED 123 #ifdef PNG_USER_MEM_SUPPORTED
125 if(png_ptr->malloc_fn != NULL) 124 if (png_ptr->malloc_fn != NULL)
126 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));
127 else 126 else
128 ret = (png_malloc_default(png_ptr, size)); 127 ret = (png_malloc_default(png_ptr, size));
129 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)
130 png_error(png_ptr, "Out of memory!"); 129 png_error(png_ptr, "Out of memory!");
131 return (ret); 130 return (ret);
132 } 131 }
133 132
134 png_voidp PNGAPI 133 png_voidp PNGAPI
135 png_malloc_default(png_structp png_ptr, png_uint_32 size) 134 png_malloc_default(png_structp png_ptr, png_uint_32 size)
(...skipping 28 matching lines...) Expand all
164 png_bytep table; 163 png_bytep table;
165 int i; 164 int i;
166 png_byte huge * hptr; 165 png_byte huge * hptr;
167 166
168 if (ret != NULL) 167 if (ret != NULL)
169 { 168 {
170 farfree(ret); 169 farfree(ret);
171 ret = NULL; 170 ret = NULL;
172 } 171 }
173 172
174 if(png_ptr->zlib_window_bits > 14) 173 if (png_ptr->zlib_window_bits > 14)
175 num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); 174 num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
176 else 175 else
177 num_blocks = 1; 176 num_blocks = 1;
178 if (png_ptr->zlib_mem_level >= 7) 177 if (png_ptr->zlib_mem_level >= 7)
179 num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); 178 num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
180 else 179 else
181 num_blocks++; 180 num_blocks++;
182 181
183 total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; 182 total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
184 183
(...skipping 18 matching lines...) Expand all
203 "Farmalloc didn't return normalized pointer"); 202 "Farmalloc didn't return normalized pointer");
204 else 203 else
205 png_warning(png_ptr, 204 png_warning(png_ptr,
206 "Farmalloc didn't return normalized pointer"); 205 "Farmalloc didn't return normalized pointer");
207 #endif 206 #endif
208 return (NULL); 207 return (NULL);
209 } 208 }
210 209
211 png_ptr->offset_table = table; 210 png_ptr->offset_table = table;
212 png_ptr->offset_table_ptr = farmalloc(num_blocks * 211 png_ptr->offset_table_ptr = farmalloc(num_blocks *
213 png_sizeof (png_bytep)); 212 png_sizeof(png_bytep));
214 213
215 if (png_ptr->offset_table_ptr == NULL) 214 if (png_ptr->offset_table_ptr == NULL)
216 { 215 {
217 #ifndef PNG_USER_MEM_SUPPORTED 216 #ifndef PNG_USER_MEM_SUPPORTED
218 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) 217 if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
219 png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ 218 png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */
220 else 219 else
221 png_warning(png_ptr, "Out Of memory."); 220 png_warning(png_ptr, "Out Of memory.");
222 #endif 221 #endif
223 return (NULL); 222 return (NULL);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ 265 png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */
267 } 266 }
268 #endif 267 #endif
269 268
270 return (ret); 269 return (ret);
271 } 270 }
272 271
273 /* free a pointer allocated by png_malloc(). In the default 272 /* free a pointer allocated by png_malloc(). In the default
274 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
275 is needed. If ptr is NULL, return without taking any action. */ 274 is needed. If ptr is NULL, return without taking any action. */
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 png_free_default(png_ptr, ptr);
289 } 289 }
290 290
291 void PNGAPI 291 void PNGAPI
292 png_free_default(png_structp png_ptr, png_voidp ptr) 292 png_free_default(png_structp png_ptr, png_voidp ptr)
293 { 293 {
294 #endif /* PNG_USER_MEM_SUPPORTED */ 294 #endif /* PNG_USER_MEM_SUPPORTED */
295 295
296 if(png_ptr == NULL || ptr == NULL) return; 296 if (png_ptr == NULL || ptr == NULL) return;
297 297
298 if (png_ptr->offset_table != NULL) 298 if (png_ptr->offset_table != NULL)
299 { 299 {
300 int i; 300 int i;
301 301
302 for (i = 0; i < png_ptr->offset_table_count; i++) 302 for (i = 0; i < png_ptr->offset_table_count; i++)
303 { 303 {
304 if (ptr == png_ptr->offset_table_ptr[i]) 304 if (ptr == png_ptr->offset_table_ptr[i])
305 { 305 {
306 ptr = NULL; 306 ptr = NULL;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 png_voidp struct_ptr; 346 png_voidp struct_ptr;
347 347
348 if (type == PNG_STRUCT_INFO) 348 if (type == PNG_STRUCT_INFO)
349 size = png_sizeof(png_info); 349 size = png_sizeof(png_info);
350 else if (type == PNG_STRUCT_PNG) 350 else if (type == PNG_STRUCT_PNG)
351 size = png_sizeof(png_struct); 351 size = png_sizeof(png_struct);
352 else 352 else
353 return (NULL); 353 return (NULL);
354 354
355 #ifdef PNG_USER_MEM_SUPPORTED 355 #ifdef PNG_USER_MEM_SUPPORTED
356 if(malloc_fn != NULL) 356 if (malloc_fn != NULL)
357 { 357 {
358 png_struct dummy_struct; 358 png_struct dummy_struct;
359 png_structp png_ptr = &dummy_struct; 359 png_structp png_ptr = &dummy_struct;
360 png_ptr->mem_ptr=mem_ptr; 360 png_ptr->mem_ptr=mem_ptr;
361 struct_ptr = (*(malloc_fn))(png_ptr, size); 361 struct_ptr = (*(malloc_fn))(png_ptr, size);
362 if (struct_ptr != NULL) 362 if (struct_ptr != NULL)
363 png_memset(struct_ptr, 0, size); 363 png_memset(struct_ptr, 0, size);
364 return (struct_ptr); 364 return (struct_ptr);
365 } 365 }
366 #endif /* PNG_USER_MEM_SUPPORTED */ 366 #endif /* PNG_USER_MEM_SUPPORTED */
367 367
368 #if defined(__TURBOC__) && !defined(__FLAT__) 368 #if defined(__TURBOC__) && !defined(__FLAT__)
369 struct_ptr = (png_voidp)farmalloc(size); 369 struct_ptr = (png_voidp)farmalloc(size);
370 #else 370 #else
371 # if defined(_MSC_VER) && defined(MAXSEG_64K) 371 # if defined(_MSC_VER) && defined(MAXSEG_64K)
372 struct_ptr = (png_voidp)halloc(size,1); 372 struct_ptr = (png_voidp)halloc(size, 1);
373 # else 373 # else
374 struct_ptr = (png_voidp)malloc(size); 374 struct_ptr = (png_voidp)malloc(size);
375 # endif 375 # endif
376 #endif 376 #endif
377 if (struct_ptr != NULL) 377 if (struct_ptr != NULL)
378 png_memset(struct_ptr, 0, size); 378 png_memset(struct_ptr, 0, size);
379 379
380 return (struct_ptr); 380 return (struct_ptr);
381 } 381 }
382 382
383 383
384 /* Free memory allocated by a png_create_struct() call */ 384 /* Free memory allocated by a png_create_struct() call */
385 void /* PRIVATE */ 385 void /* PRIVATE */
386 png_destroy_struct(png_voidp struct_ptr) 386 png_destroy_struct(png_voidp struct_ptr)
387 { 387 {
388 #ifdef PNG_USER_MEM_SUPPORTED 388 #ifdef PNG_USER_MEM_SUPPORTED
389 png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); 389 png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL);
390 } 390 }
391 391
392 /* Free memory allocated by a png_create_struct() call */ 392 /* Free memory allocated by a png_create_struct() call */
393 void /* PRIVATE */ 393 void /* PRIVATE */
394 png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, 394 png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
395 png_voidp mem_ptr) 395 png_voidp mem_ptr)
396 { 396 {
397 #endif /* PNG_USER_MEM_SUPPORTED */ 397 #endif /* PNG_USER_MEM_SUPPORTED */
398 if (struct_ptr != NULL) 398 if (struct_ptr != NULL)
399 { 399 {
400 #ifdef PNG_USER_MEM_SUPPORTED 400 #ifdef PNG_USER_MEM_SUPPORTED
401 if(free_fn != NULL) 401 if (free_fn != NULL)
402 { 402 {
403 png_struct dummy_struct; 403 png_struct dummy_struct;
404 png_structp png_ptr = &dummy_struct; 404 png_structp png_ptr = &dummy_struct;
405 png_ptr->mem_ptr=mem_ptr; 405 png_ptr->mem_ptr=mem_ptr;
406 (*(free_fn))(png_ptr, struct_ptr); 406 (*(free_fn))(png_ptr, struct_ptr);
407 return; 407 return;
408 } 408 }
409 #endif /* PNG_USER_MEM_SUPPORTED */ 409 #endif /* PNG_USER_MEM_SUPPORTED */
410 #if defined(__TURBOC__) && !defined(__FLAT__) 410 #if defined(__TURBOC__) && !defined(__FLAT__)
411 farfree(struct_ptr); 411 farfree(struct_ptr);
(...skipping 15 matching lines...) Expand all
427 427
428 png_voidp PNGAPI 428 png_voidp PNGAPI
429 png_malloc(png_structp png_ptr, png_uint_32 size) 429 png_malloc(png_structp png_ptr, png_uint_32 size)
430 { 430 {
431 png_voidp ret; 431 png_voidp ret;
432 432
433 #ifdef PNG_USER_MEM_SUPPORTED 433 #ifdef PNG_USER_MEM_SUPPORTED
434 if (png_ptr == NULL || size == 0) 434 if (png_ptr == NULL || size == 0)
435 return (NULL); 435 return (NULL);
436 436
437 if(png_ptr->malloc_fn != NULL) 437 if (png_ptr->malloc_fn != NULL)
438 ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); 438 ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
439 else 439 else
440 ret = (png_malloc_default(png_ptr, size)); 440 ret = (png_malloc_default(png_ptr, size));
441 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) 441 if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
442 png_error(png_ptr, "Out of Memory!"); 442 png_error(png_ptr, "Out of Memory!");
443 return (ret); 443 return (ret);
444 } 444 }
445 445
446 png_voidp PNGAPI 446 png_voidp PNGAPI
447 png_malloc_default(png_structp png_ptr, png_uint_32 size) 447 png_malloc_default(png_structp png_ptr, png_uint_32 size)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 /* This function was added at libpng version 1.2.3. The png_malloc_warn() 535 /* This function was added at libpng version 1.2.3. The png_malloc_warn()
536 * function will set up png_malloc() to issue a png_warning and return NULL 536 * function will set up png_malloc() to issue a png_warning and return NULL
537 * instead of issuing a png_error, if it fails to allocate the requested 537 * instead of issuing a png_error, if it fails to allocate the requested
538 * memory. 538 * memory.
539 */ 539 */
540 png_voidp PNGAPI 540 png_voidp PNGAPI
541 png_malloc_warn(png_structp png_ptr, png_uint_32 size) 541 png_malloc_warn(png_structp png_ptr, png_uint_32 size)
542 { 542 {
543 png_voidp ptr; 543 png_voidp ptr;
544 png_uint_32 save_flags; 544 png_uint_32 save_flags;
545 if(png_ptr == NULL) return (NULL); 545 if (png_ptr == NULL) return (NULL);
546 546
547 save_flags=png_ptr->flags; 547 save_flags = png_ptr->flags;
548 png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; 548 png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
549 ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); 549 ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
550 png_ptr->flags=save_flags; 550 png_ptr->flags=save_flags;
551 return(ptr); 551 return(ptr);
552 } 552 }
553 #endif 553 #endif
554 554
555 png_voidp PNGAPI 555 png_voidp PNGAPI
556 png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, 556 png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
557 png_uint_32 length) 557 png_uint_32 length)
558 { 558 {
559 png_size_t size; 559 png_size_t size;
560 560
561 size = (png_size_t)length; 561 size = (png_size_t)length;
562 if ((png_uint_32)size != length) 562 if ((png_uint_32)size != length)
563 png_error(png_ptr,"Overflow in png_memcpy_check."); 563 png_error(png_ptr, "Overflow in png_memcpy_check.");
564 564
565 return(png_memcpy (s1, s2, size)); 565 return(png_memcpy (s1, s2, size));
566 } 566 }
567 567
568 png_voidp PNGAPI 568 png_voidp PNGAPI
569 png_memset_check (png_structp png_ptr, png_voidp s1, int value, 569 png_memset_check (png_structp png_ptr, png_voidp s1, int value,
570 png_uint_32 length) 570 png_uint_32 length)
571 { 571 {
572 png_size_t size; 572 png_size_t size;
573 573
574 size = (png_size_t)length; 574 size = (png_size_t)length;
575 if ((png_uint_32)size != length) 575 if ((png_uint_32)size != length)
576 png_error(png_ptr,"Overflow in png_memset_check."); 576 png_error(png_ptr, "Overflow in png_memset_check.");
577 577
578 return (png_memset (s1, value, size)); 578 return (png_memset (s1, value, size));
579 579
580 } 580 }
581 581
582 #ifdef PNG_USER_MEM_SUPPORTED 582 #ifdef PNG_USER_MEM_SUPPORTED
583 /* This function is called when the application wants to use another method 583 /* This function is called when the application wants to use another method
584 * of allocating and freeing memory. 584 * of allocating and freeing memory.
585 */ 585 */
586 void PNGAPI 586 void PNGAPI
587 png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr 587 png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
588 malloc_fn, png_free_ptr free_fn) 588 malloc_fn, png_free_ptr free_fn)
589 { 589 {
590 if(png_ptr != NULL) { 590 if (png_ptr != NULL)
591 png_ptr->mem_ptr = mem_ptr; 591 {
592 png_ptr->malloc_fn = malloc_fn; 592 png_ptr->mem_ptr = mem_ptr;
593 png_ptr->free_fn = free_fn; 593 png_ptr->malloc_fn = malloc_fn;
594 png_ptr->free_fn = free_fn;
594 } 595 }
595 } 596 }
596 597
597 /* This function returns a pointer to the mem_ptr associated with the user 598 /* This function returns a pointer to the mem_ptr associated with the user
598 * functions. The application should free any memory associated with this 599 * functions. The application should free any memory associated with this
599 * pointer before png_write_destroy and png_read_destroy are called. 600 * pointer before png_write_destroy and png_read_destroy are called.
600 */ 601 */
601 png_voidp PNGAPI 602 png_voidp PNGAPI
602 png_get_mem_ptr(png_structp png_ptr) 603 png_get_mem_ptr(png_structp png_ptr)
603 { 604 {
604 if(png_ptr == NULL) return (NULL); 605 if (png_ptr == NULL) return (NULL);
605 return ((png_voidp)png_ptr->mem_ptr); 606 return ((png_voidp)png_ptr->mem_ptr);
606 } 607 }
607 #endif /* PNG_USER_MEM_SUPPORTED */ 608 #endif /* PNG_USER_MEM_SUPPORTED */
608 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ 609 #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
OLDNEW
« no previous file with comments | « third_party/libpng/pngget.c ('k') | third_party/libpng/pngpread.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698