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

Side by Side Diff: src/base/ftdbgmem.c

Issue 89753003: Update freetype to latest version of ASOP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 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
« no previous file with comments | « src/base/ftcalc.c ('k') | src/base/ftdebug.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 /* */ 2 /* */
3 /* ftdbgmem.c */ 3 /* ftdbgmem.c */
4 /* */ 4 /* */
5 /* Memory debugger (body). */ 5 /* Memory debugger (body). */
6 /* */ 6 /* */
7 /* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2009 by */ 7 /* Copyright 2001-2006, 2009, 2013 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */ 9 /* */
10 /* This file is part of the FreeType project, and may only be used, */ 10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */ 11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */ 13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */ 14 /* understand and accept it fully. */
15 /* */ 15 /* */
16 /***************************************************************************/ 16 /***************************************************************************/
17 17
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 Exit: 338 Exit:
339 return table; 339 return table;
340 } 340 }
341 341
342 342
343 static void 343 static void
344 ft_mem_table_destroy( FT_MemTable table ) 344 ft_mem_table_destroy( FT_MemTable table )
345 { 345 {
346 FT_ULong i; 346 FT_ULong i;
347 FT_Long leak_count = 0;
348 FT_ULong leaks = 0;
347 349
348 350
349 FT_DumpMemory( table->memory ); 351 FT_DumpMemory( table->memory );
350 352
351 if ( table ) 353 /* remove all blocks from the table, revealing leaked ones */
354 for ( i = 0; i < table->size; i++ )
352 { 355 {
353 FT_Long leak_count = 0; 356 FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
354 FT_ULong leaks = 0;
355 357
356 358
357 /* remove all blocks from the table, revealing leaked ones */ 359 while ( node )
358 for ( i = 0; i < table->size; i++ )
359 { 360 {
360 FT_MemNode *pnode = table->buckets + i, next, node = *pnode; 361 next = node->link;
362 node->link = 0;
363
364 if ( node->size > 0 )
365 {
366 printf(
367 "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
368 node->address, node->size,
369 FT_FILENAME( node->source->file_name ),
370 node->source->line_no );
371
372 leak_count++;
373 leaks += node->size;
374
375 ft_mem_table_free( table, node->address );
376 }
377
378 node->address = NULL;
379 node->size = 0;
380
381 ft_mem_table_free( table, node );
382 node = next;
383 }
384 table->buckets[i] = 0;
385 }
386
387 ft_mem_table_free( table, table->buckets );
388 table->buckets = NULL;
389
390 table->size = 0;
391 table->nodes = 0;
392
393 /* remove all sources */
394 for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
395 {
396 FT_MemSource source, next;
361 397
362 398
363 while ( node ) 399 for ( source = table->sources[i]; source != NULL; source = next )
364 { 400 {
365 next = node->link; 401 next = source->link;
366 node->link = 0; 402 ft_mem_table_free( table, source );
367
368 if ( node->size > 0 )
369 {
370 printf(
371 "leaked memory block at address %p, size %8ld in (%s:%ld)\n",
372 node->address, node->size,
373 FT_FILENAME( node->source->file_name ),
374 node->source->line_no );
375
376 leak_count++;
377 leaks += node->size;
378
379 ft_mem_table_free( table, node->address );
380 }
381
382 node->address = NULL;
383 node->size = 0;
384
385 ft_mem_table_free( table, node );
386 node = next;
387 }
388 table->buckets[i] = 0;
389 } 403 }
390 404
391 ft_mem_table_free( table, table->buckets ); 405 table->sources[i] = NULL;
392 table->buckets = NULL; 406 }
393 407
394 table->size = 0; 408 printf( "FreeType: total memory allocations = %ld\n",
395 table->nodes = 0; 409 table->alloc_total );
410 printf( "FreeType: maximum memory footprint = %ld\n",
411 table->alloc_max );
396 412
397 /* remove all sources */ 413 ft_mem_table_free( table, table );
398 for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
399 {
400 FT_MemSource source, next;
401 414
415 if ( leak_count > 0 )
416 ft_mem_debug_panic(
417 "FreeType: %ld bytes of memory leaked in %ld blocks\n",
418 leaks, leak_count );
402 419
403 for ( source = table->sources[i]; source != NULL; source = next ) 420 printf( "FreeType: no memory leaks detected\n" );
404 {
405 next = source->link;
406 ft_mem_table_free( table, source );
407 }
408
409 table->sources[i] = NULL;
410 }
411
412 printf(
413 "FreeType: total memory allocations = %ld\n", table->alloc_total );
414 printf(
415 "FreeType: maximum memory footprint = %ld\n", table->alloc_max );
416
417 ft_mem_table_free( table, table );
418
419 if ( leak_count > 0 )
420 ft_mem_debug_panic(
421 "FreeType: %ld bytes of memory leaked in %ld blocks\n",
422 leaks, leak_count );
423
424 printf( "FreeType: no memory leaks detected\n" );
425 }
426 } 421 }
427 422
428 423
429 static FT_MemNode* 424 static FT_MemNode*
430 ft_mem_table_get_nodep( FT_MemTable table, 425 ft_mem_table_get_nodep( FT_MemTable table,
431 FT_Byte* address ) 426 FT_Byte* address )
432 { 427 {
433 FT_PtrDist hash; 428 FT_PtrDist hash;
434 FT_MemNode *pnode, node; 429 FT_MemNode *pnode, node;
435 430
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 983
989 #else /* !FT_DEBUG_MEMORY */ 984 #else /* !FT_DEBUG_MEMORY */
990 985
991 /* ANSI C doesn't like empty source files */ 986 /* ANSI C doesn't like empty source files */
992 typedef int _debug_mem_dummy; 987 typedef int _debug_mem_dummy;
993 988
994 #endif /* !FT_DEBUG_MEMORY */ 989 #endif /* !FT_DEBUG_MEMORY */
995 990
996 991
997 /* END */ 992 /* END */
OLDNEW
« no previous file with comments | « src/base/ftcalc.c ('k') | src/base/ftdebug.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698