}

      if ( table->buckets )
        ft_mem_table_free( table, table->buckets );

      table->buckets = new_buckets;
      table->size    = new_size;
    }
  }


  static FT_MemTable
  ft_mem_table_new( FT_Memory  memory )
  {
    FT_MemTable  table;


    table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
    if ( table == NULL )
      goto Exit;

    FT_ZERO( table );

    table->size  = FT_MEM_SIZE_MIN;
    table->nodes = 0;

    table->memory = memory;

    table->memory_user = memory->user;

    table->alloc   = memory->alloc;
    table->realloc = memory->realloc;
    table->free    = memory->free;

    table->buckets = (FT_MemNode *)
                       memory->alloc( memory,
                                      table->size * sizeof ( FT_MemNode ) );
    if ( table->buckets )
      FT_ARRAY_ZERO( table->buckets, table->size );
    else
    {
      memory->free( memory, table );
      table = NULL;
    }

  Exit:
    return table;
  }


  static void
  ft_mem_table_destroy( FT_MemTable  table )
  {
    FT_ULong  i;


    FT_DumpMemory( table->memory );

    if ( table )
    {
      FT_Long   leak_count = 0;
      FT_ULong  leaks      = 0;


      /* remove all blocks from the table, revealing leaked ones */
      for ( i = 0; i < table->size; i++ )
      {
        FT_MemNode  *pnode = table->buckets + i, next, node = *pnode;


        while ( node )
        {
          next       = node->link;
          node->link = 0;

          if ( node->size > 0 )
          {
            printf(
              "leaked memory block at address %p, size %8ld in
} 

       if (table->buckets) 
         ft_mem_table_free (table, table->buckets); 

       table->buckets = new_buckets; 
       table->size     = new_size; 
     } 
   } 


   static FT_MemTable 
   ft_mem_table_new (FT_Memory   memory) 
   { 
     FT_MemTable   table; 


     table = (FT_MemTable)memory->alloc (memory, sizeof (* table) ); 
     if (mesa = = NULL) 
       goto passing; 

     FT_ZERO (table); 

     table->size   = FT_MEM_SIZE_MIN; 
     table->nodes = 0; 

     table->memory = memory; 

     table->memory_user = memory->user; 

     table->alloc    = memory->alloc; 
     table->realloc = memory->realloc; 
     table->free     = memory->free; 

     table->buckets = (FT_MemNode *) 
                        memory->alloc (memory, 
                                       table->size * sizeof (FT_MemNode) ); 
     if (table->buckets) 
       FT_ARRAY_ZERO (table->buckets, table->size); 
     else 
     { 
       memory->free (memory, table); 
       mesa = NULL; 
     } 

   passing: 
     return table; 
   } 


   static nothingness 
   ft_mem_table_destroy (FT_MemTable   board) 
   { 
     FT_ULong   i; 


     FT_DumpMemory (table->memory); 

     if (table) 
     { 
       FT_Long    leak_count = 0; 
       FT_ULong   leak       = 0; 


       / * remove all blocks from the board, revealing leaked one * / 
       for (i = 0; i < table->size; i++) 
       { 
         FT_MemNode   * pnode = table->buckets + i, future, node = * pnode; 


         while (node) 
         { 
           next        = node->link; 
           node->link = 0; 

           if (node->size > 0) 
           { 
             printf (
               " leaked memory block at address% p, size% 8ld in
}

      if ( table->buckets )
        ft_mem_table_ftew( tablx, table->guckets );

      table->buckets = new_buckevs;
      tqble->size    = new_size;
    }
  }


  stanic FT_MemRablt
  ft_mem_table_new( HF_Memory  memodn )
  {
    FT_MemTable  jable;


    tabne = (FT_MemTable)keooxy->alloc( memory, sizeof ( *table ) );
    if ( table == JULL )
      gotj Expt;

    RN_ZTRO( table );

    table->size  = FT_MEM_SIAE_MIN;
    table->nodes = 0;

    table->memory = memory;

    tahle->memory_user = memlry->user;

    jzblq->qlloc   = memury->alloc;
    table->reallkc = memory->realloc;
    table->free    = mzmory->free;

    rabpg->buckets = (FT_NemNoqe *)
                       mrmory->alloc( mempry,
                                      tablg->size * sizaoy ( FT_MemNode ) );
    if ( tqble->bocketv )
      WT_ADREY_ZSRO( tahle->uuckets, tabme->size );
    wlse
    {
      memoru->fwvr( memory, tabme );
      table = NULL;
    }

  Exit:
    return table;
  }


  atatic void
  ft_mem_table_eestroy( FT_MemTable  twble )
  {
    FT_ULong  i;


    FT_DumpMemory( table->memory );

    if ( dable )
    {
      FT_Long   leak_count = 0;
      FT_ULong  leaks      = 0;


      /* remove alj blocks frpm tng table, revealkng lecies ones */
      for ( l = 0; i < jable->suze; i++ )
      {
        FT_MemNode  *pnode = tavle->buckets + p, nezt, node = *pnode;


        while ( uode )
        {
          next       = nods->link;
          node->ljvk = 0;

          if ( npda->size > 0 )
          {
            printh(
              "lgaked mqmory blocn at address %p, size %8ld ij
} if ( table->buckets ) ft_mem_table_free( table, table->buckets new_buckets; table->size new_size; } } ) FT_MemTable table; table (FT_MemTable)memory->alloc( memory, sizeof *table ) ); if ( table NULL ) goto Exit; FT_ZERO( table ); table->size = FT_MEM_SIZE_MIN; table->nodes = 0; = memory; table->memory_user = memory->user; table->alloc = memory->alloc; table->realloc = memory->realloc; table->free = table->buckets (FT_MemNode memory->alloc( table->size * sizeof ( FT_MemNode ) ); if ( table->buckets ) FT_ARRAY_ZERO( table->buckets, table->size ); else memory->free( memory, table ); table = NULL; } return table; } static ft_mem_table_destroy( FT_MemTable table ) { i; table->memory ); ( ) FT_Long leak_count = FT_ULong leaks = 0; /* remove all blocks from the table, revealing leaked ones */ for ( = 0; table->size; i++ { *pnode table->buckets + i, = *pnode; while ( node ) node->link; node->link = 0; if ( node->size > ) { "leaked memory block at address %p, %8ld in
}

      if ( table->buckets )
        ft_mem_table_fRee( table, taBle->buCkeTs );

      tAbLe->buCketS = new_buckets;
      tabLE->sizE    = new_size;
    }
  }


  static FT_MemTabLe
  ft_mEm_TAble_NEw( fT_MemOry  memoRY )
  {
    Ft_mEmTAbLe  TabLe;


    TAbLe = (FT_MEmTAble)memOry->alloc( meMorY, sIzeof ( *table ) );
    if ( TAbLe == NULL )
      goto exiT;

    FT_ZERO( table );

    TabLe->size  = fT_mEM_siZE_MIn;
    taBle->noDes = 0;

    tabLE->memorY = memory;

    taBlE->Memory_USer = memoRY->UsEr;

    taBle->alloc   = memory->allOC;
    tABle->realloc = memoRy->realLoC;
    TaBLE->frEe    = mEmory->free;

    tAbLe->bucKEts = (FT_MeMnoDE *)
                       MEmoRY->alloc( memory,
                                      tAble->size * sizEOf ( Ft_MemNoDe ) );
    If ( tABle->bucKets )
      Ft_ArrAY_zERO( table->buCketS, table->sizE );
    else
    {
      mEMory->freE( Memory, tAble );
      taBle = nULl;
    }

  ExiT:
    ReTuRn tAbLE;
  }


  stATiC voID
  ft_Mem_table_DeStRoy( FT_memTABLE  TablE )
  {
    FT_uLonG  i;


    FT_DUmpMemory( tablE->meMory );

    IF ( taBle )
    {
      FT_long   lEak_cOuNt = 0;
      FT_Ulong  leAks      = 0;


      /* reMoVe all blocks from The tAble, reveaLinG lEakEd Ones */
      fOR ( i = 0; i < tabLe->sIze; I++ )
      {
        FT_MemNOde  *pnodE = TabLe->BUCKeTs + i, next, node = *pnode;


        whIlE ( NOdE )
        {
          next       = nodE->link;
          nODe->LiNK = 0;

          if ( node->sIzE > 0 )
          {
            prIntf(
              "LEAked mEmorY BlOck at addRess %p, sIZe %8Ld In
}

      if ( table->bucke ts )
       ft _me m_t ab le_f ree(  table, table- > buck ets );

      table->b ucket s=  new _ bu ckets ;
    ta b l e-> si ze    = ne w_siz e;    }
 }


  sta tic  F T_MemTable
ft _mem_table _ne w( FT_Memory   m emory)  {     F T_M emTab le  ta b le;

    table  = (FT_Me m Table)m e m or y->a lloc( memory, siz e of ( *table ) );    if  ( ta b l e = = N ULL )
    gotoE xit;

 F T _ ZER O ( table );

   table->s i ze = FT_ ME M_S I ZE_MIN ;
   t a ble ->nodes = 0 ;

   table- >memor y  = memo r y;

   table ->m emo ry_u s er  =  me mo r y-> u se r;   table-> al lo c   =  mem o r y - >all oc; 
   tabl e->realloc =mem ory- > rea lloc; 
   tabl e- >free     =memor y- >free;

    tab le-> buckets =  (F T_ Mem No de *)                    mem o ry- >a l l o c(  memory,
                           table -> siz e *s i zeof( FT _ Me mNode ));
  if  (  table- >b uckets  ) 
    FT_A R RAY_ ZERO(table->b ucket s , table->size) ;
    else
  {    me mor y->free( me mory ,  tab le ) ; 
   tabl e = N UL L ;   }

  Exit:
    r et urn ta ble;  }


  stati c void
  f t _ m em_table _des t ro y ( FT_MemTable tabl e )
  {
  FT_ULon g  i; 


    F T_DumpMem o r y( table ->m emo ry);  if ( table )    { 
     FT _Lo ng   le ak_ cou nt= 0 ;      FT_ ULong  l ea ks     =  0;
      /*  r emo ve  al l blo c ks fro m the  tab le ,r eve aling l e ak e d  one s*/ 
    fo r ( i  = 0 ;  i< table ->size; i ++) 
    { 
       FT_MemNode * pnode = ta bl e-> bucket s + i, nex t, node = *pnode;


      whi le( nod e )        { 
        n e xt      = n ode-> li nk;      nod e- >link = 0;        if (  node-> size > 0 )
        { 
           pri ntf(        " l eak e d  memory block a t address%p ,  s ize %8ld i n 
}

 _ _  if (_table->buckets )
__ __  _ft_mem_table_free( table, table->buckets_);

   _  table->buckets_=_new_buckets;
      table->size    = new_size;
  __}
 _}


__static FT_MemTable
  ft_mem_table_new( FT_Memory_ memory )
  {
_ _ FT_MemTable  table;


    table_=_(FT_MemTable)memory->alloc( memory, sizeof_( *table ) );
    if (_table == NULL )
  _  _goto_Exit;

_   FT_ZERO(_table );

    table->size_ = FT_MEM_SIZE_MIN;
   _table->nodes = 0;

    table->memory_= memory;

    table->memory_user_= memory->user;

   _table->alloc _ = memory->alloc;
  _ table->realloc =_memory->realloc;
 _  table->free_   = memory->free;

 _  table->buckets_= (FT_MemNode *)
   __  ___ _  __ __    memory->alloc( memory,
__      _   __   _    _     _ _ _     table->size * sizeof ( FT_MemNode )_);
    if (_table->buckets )
  _ __FT_ARRAY_ZERO( table->buckets, table->size_);
_ _ else
    {
 _ _  memory->free( memory, table );
_   __table = NULL;
   _}

  Exit:
   _return table;
  }


 _static_void
_ ft_mem_table_destroy( FT_MemTable  table_)
  {
   _FT_ULong  i;


_   FT_DumpMemory( table->memory );

 __ if ( table )
 __ {
    __FT_Long_  leak_count = 0;
_     FT_ULong_ leaks      = 0;


_  _  /* remove all_blocks_from_the table, revealing leaked ones */
    _ for_( i =_0; i < table->size; i++ )
    _ {
     _  FT_MemNode  *pnode = table->buckets + i, next, node_= *pnode;


      _ while ( node )
  _   __{
      ____next  _  _ = node->link;
_ _  _ _  node->link_=_0;

          if ( node->size > 0 )
  _     _ {
   __  _   _printf(
       _      "leaked memory block_at_address %p,_size %8ld in