Home | History | Annotate | Download | only in base

Lines Matching refs:table

226   ft_mem_table_alloc( FT_MemTable  table,
229 FT_Memory memory = table->memory;
233 memory->user = table->memory_user;
234 block = table->alloc( memory, size );
235 memory->user = table;
242 ft_mem_table_free( FT_MemTable table,
245 FT_Memory memory = table->memory;
248 memory->user = table->memory_user;
249 table->free( memory, block );
250 memory->user = table;
255 ft_mem_table_resize( FT_MemTable table )
260 new_size = ft_mem_closest_prime( table->nodes );
261 if ( new_size != table->size )
269 table,
276 for ( i = 0; i < table->size; i++ )
282 node = table->buckets[i];
296 if ( table->buckets )
297 ft_mem_table_free( table, table->buckets );
299 table->buckets = new_buckets;
300 table->size = new_size;
308 FT_MemTable table;
311 table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
312 if ( table == NULL )
315 FT_ZERO( table );
317 table->size = FT_MEM_SIZE_MIN;
318 table->nodes = 0;
320 table->memory = memory;
322 table->memory_user = memory->user;
324 table->alloc = memory->alloc;
325 table->realloc = memory->realloc;
326 table->free = memory->free;
328 table->buckets = (FT_MemNode *)
331 table->size * (FT_Long)sizeof ( FT_MemNode ) );
332 if ( table->buckets )
333 FT_ARRAY_ZERO( table->buckets, table->size );
336 memory->free( memory, table );
337 table = NULL;
341 return table;
346 ft_mem_table_destroy( FT_MemTable table )
353 FT_DumpMemory( table->memory );
355 /* remove all blocks from the table, revealing leaked ones */
356 for ( i = 0; i < table->size; i++ )
358 FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
377 ft_mem_table_free( table, node->address );
383 ft_mem_table_free( table, node );
386 table->buckets[i] = NULL;
389 ft_mem_table_free( table, table->buckets );
390 table->buckets = NULL;
392 table->size = 0;
393 table->nodes = 0;
401 for ( source = table->sources[i]; source != NULL; source = next )
404 ft_mem_table_free( table, source );
407 table->sources[i] = NULL;
411 table->alloc_total );
413 table->alloc_max );
415 ft_mem_table_free( table, table );
427 ft_mem_table_get_nodep( FT_MemTable table,
435 pnode = table->buckets + ( hash % (FT_PtrDist)table->size );
453 ft_mem_table_get_source( FT_MemTable table )
463 pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS];
478 node = (FT_MemSource)ft_mem_table_alloc( table, sizeof ( *node ) );
506 ft_mem_table_set( FT_MemTable table,
514 if ( table )
519 pnode = ft_mem_table_get_nodep( table, address );
545 /* we need to create a new node in this table */
546 node = (FT_MemNode)ft_mem_table_alloc( table, sizeof ( *node ) );
552 node->source = source = ft_mem_table_get_source( table );
570 table->alloc_current += delta;
576 table->alloc_current += size;
590 table->nodes++;
592 table->alloc_total += size;
594 if ( table->alloc_current > table->alloc_max )
595 table->alloc_max = table->alloc_current;
597 if ( table->nodes * 3 < table->size ||
598 table->size * 3 < table->nodes )
599 ft_mem_table_resize( table );
605 ft_mem_table_remove( FT_MemTable table,
609 if ( table )
614 pnode = ft_mem_table_get_nodep( table, address );
640 table->alloc_current -= node->size;
643 if ( table->keep_alive )
653 table->nodes--;
660 ft_mem_table_free( table, node );
662 if ( table->nodes * 3 < table->size ||
663 table->size * 3 < table->nodes )
664 table );
680 FT_MemTable table = (FT_MemTable)memory->user;
688 if ( table->bound_count &&
689 table->alloc_count >= table->alloc_count_max )
693 if ( table->bound_total &&
694 table->alloc_total_max - table->alloc_current > size )
697 block = (FT_Byte *)ft_mem_table_alloc( table, size );
700 ft_mem_table_set( table, block, size, 0 );
702 table->alloc_count++;
716 FT_MemTable table = (FT_MemTable)memory->user;
724 ft_mem_table_remove( table, (FT_Byte*)block, 0 );
726 if ( !table->keep_alive )
727 ft_mem_table_free( table, block );
729 table->alloc_count--;
742 FT_MemTable table = (FT_MemTable)memory->user;
770 pnode = ft_mem_table_get_nodep( table, (FT_Byte*)block );
788 if ( table->bound_count &&
789 table->alloc_count >= table->alloc_count_max )
796 table->bound_total &&
797 table->alloc_current + delta > table->alloc_total_max )
800 new_block = (FT_Pointer)ft_mem_table_alloc( table, new_size );
804 ft_mem_table_set( table, (FT_Byte*)new_block, new_size, delta );
809 ft_mem_table_remove( table, (FT_Byte*)block, delta );
814 if ( !table->keep_alive )
815 ft_mem_table_free( table, block );
824 FT_MemTable table;
830 table = ft_mem_table_new( memory );
831 if ( table )
836 memory->user = table;
849 table->bound_total = 1;
850 table->alloc_total_max = total_max;
862 table->bound_count = 1;
863 table->alloc_count_max = total_count;
874 table->keep_alive = 1;
887 FT_MemTable table = (FT_MemTable)memory->user;
890 if ( table )
892 memory->free = table->free;
893 memory->realloc = table->realloc;
894 memory->alloc = table->alloc;
896 ft_mem_table_destroy( table );
922 FT_MemTable table = (FT_MemTable)memory->user;
925 if ( table )
927 FT_MemSource* bucket = table->sources;
946 table, count * (FT_Long)sizeof ( *sources ) );
949 for ( bucket = table->sources; bucket < limit; bucket++ )
965 table->alloc_current, table->alloc_max,
966 table->alloc_total, table->alloc_count );
986 ft_mem_table_free( table, sources );