... |
... |
@@ -302,46 +302,6 @@ |
302
|
302
|
}
|
303
|
303
|
|
304
|
304
|
|
305
|
|
- static FT_MemTable
|
306
|
|
- ft_mem_table_new( FT_Memory memory )
|
307
|
|
- {
|
308
|
|
- FT_MemTable table;
|
309
|
|
-
|
310
|
|
-
|
311
|
|
- table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
|
312
|
|
- if ( !table )
|
313
|
|
- goto Exit;
|
314
|
|
-
|
315
|
|
- FT_ZERO( table );
|
316
|
|
-
|
317
|
|
- table->size = FT_MEM_SIZE_MIN;
|
318
|
|
- table->nodes = 0;
|
319
|
|
-
|
320
|
|
- table->memory = memory;
|
321
|
|
-
|
322
|
|
- table->memory_user = memory->user;
|
323
|
|
-
|
324
|
|
- table->alloc = memory->alloc;
|
325
|
|
- table->realloc = memory->realloc;
|
326
|
|
- table->free = memory->free;
|
327
|
|
-
|
328
|
|
- table->buckets = (FT_MemNode *)
|
329
|
|
- memory->alloc(
|
330
|
|
- memory,
|
331
|
|
- table->size * (FT_Long)sizeof ( FT_MemNode ) );
|
332
|
|
- if ( table->buckets )
|
333
|
|
- FT_ARRAY_ZERO( table->buckets, table->size );
|
334
|
|
- else
|
335
|
|
- {
|
336
|
|
- memory->free( memory, table );
|
337
|
|
- table = NULL;
|
338
|
|
- }
|
339
|
|
-
|
340
|
|
- Exit:
|
341
|
|
- return table;
|
342
|
|
- }
|
343
|
|
-
|
344
|
|
-
|
345
|
305
|
static void
|
346
|
306
|
ft_mem_table_destroy( FT_MemTable table )
|
347
|
307
|
{
|
... |
... |
@@ -413,8 +373,6 @@ |
413
|
373
|
printf( "FreeType: maximum memory footprint = %ld\n",
|
414
|
374
|
table->alloc_max );
|
415
|
375
|
|
416
|
|
- ft_mem_table_free( table, table );
|
417
|
|
-
|
418
|
376
|
if ( leak_count > 0 )
|
419
|
377
|
ft_mem_debug_panic(
|
420
|
378
|
"FreeType: %ld bytes of memory leaked in %ld blocks\n",
|
... |
... |
@@ -821,17 +779,30 @@ |
821
|
779
|
}
|
822
|
780
|
|
823
|
781
|
|
824
|
|
- extern FT_Int
|
|
782
|
+ extern void
|
825
|
783
|
ft_mem_debug_init( FT_Memory memory )
|
826
|
784
|
{
|
827
|
785
|
FT_MemTable table;
|
828
|
|
- FT_Int result = 0;
|
829
|
786
|
|
830
|
787
|
|
831
|
|
- if ( ft_getenv( "FT2_DEBUG_MEMORY" ) )
|
|
788
|
+ if ( !ft_getenv( "FT2_DEBUG_MEMORY" ) )
|
|
789
|
+ return;
|
|
790
|
+
|
|
791
|
+ table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
|
|
792
|
+
|
|
793
|
+ if ( table )
|
832
|
794
|
{
|
833
|
|
- table = ft_mem_table_new( memory );
|
834
|
|
- if ( table )
|
|
795
|
+ FT_ZERO( table );
|
|
796
|
+
|
|
797
|
+ table->memory = memory;
|
|
798
|
+ table->memory_user = memory->user;
|
|
799
|
+ table->alloc = memory->alloc;
|
|
800
|
+ table->realloc = memory->realloc;
|
|
801
|
+ table->free = memory->free;
|
|
802
|
+
|
|
803
|
+ ft_mem_table_resize( table );
|
|
804
|
+
|
|
805
|
+ if ( table->size )
|
835
|
806
|
{
|
836
|
807
|
const char* p;
|
837
|
808
|
|
... |
... |
@@ -876,28 +847,29 @@ |
876
|
847
|
if ( keep_alive > 0 )
|
877
|
848
|
table->keep_alive = 1;
|
878
|
849
|
}
|
879
|
|
-
|
880
|
|
- result = 1;
|
881
|
850
|
}
|
|
851
|
+ else
|
|
852
|
+ memory->free( memory, table );
|
882
|
853
|
}
|
883
|
|
- return result;
|
884
|
854
|
}
|
885
|
855
|
|
886
|
856
|
|
887
|
857
|
extern void
|
888
|
858
|
ft_mem_debug_done( FT_Memory memory )
|
889
|
859
|
{
|
890
|
|
- FT_MemTable table = (FT_MemTable)memory->user;
|
|
860
|
+ if ( memory->free == ft_mem_debug_free )
|
|
861
|
+ {
|
|
862
|
+ FT_MemTable table = (FT_MemTable)memory->user;
|
891
|
863
|
|
892
|
864
|
|
893
|
|
- if ( table )
|
894
|
|
- {
|
|
865
|
+ ft_mem_table_destroy( table );
|
|
866
|
+
|
895
|
867
|
memory->free = table->free;
|
896
|
868
|
memory->realloc = table->realloc;
|
897
|
869
|
memory->alloc = table->alloc;
|
|
870
|
+ memory->user = table->memory_user;
|
898
|
871
|
|
899
|
|
- ft_mem_table_destroy( table );
|
900
|
|
- memory->user = NULL;
|
|
872
|
+ memory->free( memory, table );
|
901
|
873
|
}
|
902
|
874
|
}
|
903
|
875
|
|