Changeset f103fb in git


Ignore:
Timestamp:
Oct 4, 2000, 3:12:32 PM (24 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
400633927935ad03438bf37f1f7967d1b891903d
Parents:
ff4e34fa88e2957ee964d2e38c9e058cf143c963
Message:
* omGetStickyBinOfBin added


git-svn-id: file:///usr/local/Singular/svn/trunk@4638 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
omalloc
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • omalloc/omAlloc.c

    rff4e34f rf103fb  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omAlloc.c,v 1.8 2000-08-14 12:26:38 obachman Exp $
     6 *  Version: $Id: omAlloc.c,v 1.9 2000-10-04 13:12:28 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_ALLOC_C
     
    134134  }
    135135
    136   if (bin->current_page->next != NULL)
     136  if (!bin->sticky && bin->current_page->next != NULL)
    137137  {
    138138    omAssume(bin->current_page->next->current != NULL);
     
    145145    omInsertBinPage(bin->current_page, newpage, bin);
    146146  }
     147   
    147148  bin->current_page = newpage;
    148  
    149149  omAssume(newpage != NULL && newpage != om_ZeroPage &&
    150150           newpage->current != NULL);
     
    207207#else
    208208#  if defined(PAGE_AFTER_CURRENT)
    209     omInsertBinPage(bin->current_page, page, bin);
     209      omInsertBinPage(bin->current_page, page, bin);
    210210#  else
    211     omInsertBinPage(bin->last_page, page, bin);
     211      omInsertBinPage(bin->last_page, page, bin);
    212212#  endif
    213213#endif
  • omalloc/omAllocPrivate.h

    rff4e34f rf103fb  
    55 *  Author:  obachman (Olaf Bachmann)
    66 *  Created: 11/99
    7  *  Version: $Id: omAllocPrivate.h,v 1.4 2000-08-18 09:05:51 obachman Exp $
     7 *  Version: $Id: omAllocPrivate.h,v 1.5 2000-10-04 13:12:28 obachman Exp $
    88 *******************************************************************/
    99#ifndef OM_ALLOC_PRIVATE_H
     
    5353};
    5454
    55 extern  omSpecBin om_SpecBin;
     55extern  omSpecBin   om_SpecBin;
     56extern  omBin       om_StickyBins;
    5657extern  omBinPage_t om_ZeroPage[];
    5758extern  omBin       om_Size2Bin[];
     
    6970  (page)->bin_sticky= (void*)((unsigned long)bin + omGetStickyOfPage(page))
    7071#define omSetStickyOfPage(page, sticky) \
    71   (page)->bin_sticky = (void*)((unsigned long)sticky + \
     72  (page)->bin_sticky = (void*)(((unsigned long)sticky & (SIZEOF_VOIDP-1)) + \
    7273                                (unsigned long)omGetTopBinOfPage(page))
    7374#define omSetTopBinAndStickyOfPage(page, bin, sticky) \
    74   (page)->bin_sticky= (void*)((unsigned long)sticky + (unsigned long)bin)
     75  (page)->bin_sticky= (void*)(((unsigned long)sticky & (SIZEOF_VOIDP-1)) \
     76                               + (unsigned long)bin)
    7577
    7678#define omGetTopBinOfAddr(addr) \
  • omalloc/omBin.c

    rff4e34f rf103fb  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omBin.c,v 1.3 2000-08-14 12:26:40 obachman Exp $
     6 *  Version: $Id: omBin.c,v 1.4 2000-10-04 13:12:28 obachman Exp $
    77 *******************************************************************/
    88
     
    157157        s_bin = omFindInSortedGList(om_SpecBin, next, max_blocks, bin->max_blocks);
    158158       
    159     omAssume(s_bin != NULL);
     159    omAssume(s_bin != NULL && bin == s_bin->bin);
    160160    if (s_bin != NULL)
    161161    {
     
    163163      if (s_bin->ref == 0 || force)
    164164      {
     165#ifdef OM_HAVE_TRACK
     166        if (! track_bin)
     167#endif
     168          omFreeKeptAddrFromBin(s_bin->bin);
    165169        if(s_bin->bin->last_page == NULL || force)
    166170        {
     
    180184}
    181185
    182 /*****************************************************************
    183  *
    184  * Statistics
    185  *
    186  *****************************************************************/
    187 static void omGetBinStat(omBin bin, int *pages_p, int *used_blocks_p,
    188                           int *free_blocks_p)
    189 {
    190   int pages = 0, used_blocks = 0, free_blocks = 0;
    191   int where = 1;
    192  
    193   omBinPage page = bin->last_page;
    194   while (page != NULL)
    195   {
    196     pages++; if (where == 1)
    197     {
    198       used_blocks += omGetUsedBlocksOfPage(page) + 1;
    199       if (bin->max_blocks > 0)
    200         free_blocks += bin->max_blocks - omGetUsedBlocksOfPage(page) -1;
    201     }
    202     else
    203     {
    204       if (bin->max_blocks > 1)
    205         used_blocks += bin->max_blocks;
    206       else
    207         used_blocks++;
    208     }
    209     if (page == bin->current_page) where = -1;
    210     page = page->prev;
    211   }
    212   *pages_p = pages;
    213   *used_blocks_p = used_blocks;
    214   *free_blocks_p = free_blocks;
    215 }
    216 
    217 static void omGetTotalBinStat(omBin bin, int *pages_p, int *used_blocks_p,
    218                                int *free_blocks_p)
    219 {
    220   int t_pages = 0, t_used_blocks = 0, t_free_blocks = 0;
    221   int pages = 0, used_blocks = 0, free_blocks = 0;
    222  
    223   while (bin != NULL)
    224   {
    225     omGetBinStat(bin, &pages, &used_blocks, &free_blocks);
    226     t_pages += pages;
    227     t_used_blocks += used_blocks;
    228     t_free_blocks += free_blocks;
    229     bin = bin->next;
    230   }
    231   *pages_p = t_pages;
    232   *used_blocks_p = t_used_blocks;
    233   *free_blocks_p = t_free_blocks;
    234 }
    235 
    236 static void omPrintBinStat(FILE * fd, omBin bin, int track, int* pages, int* used_blocks, int* free_blocks)
    237 {
    238   if (track)
    239   {
    240     fprintf(fd, "T \t \t");
    241   }
    242   else
    243   {
    244     fprintf(fd, "%s%u\t%ld\t", (omIsStaticNormalBin(bin) ? " " : (omIsTrackBin(bin) ? "T" : "*")),
    245             bin->sizeW, bin->max_blocks);
    246   }
    247   omGetTotalBinStat(bin, pages, used_blocks, free_blocks);
    248   fprintf(fd, "%d\t%d\t%d\n", *pages, *free_blocks, *used_blocks);
    249   if (bin->next != NULL)
    250   {
    251     int s_pages, s_free_blocks, s_used_blocks;
    252     while (bin != NULL)
    253     {
    254       omGetBinStat(bin, &s_pages, &s_used_blocks, &s_free_blocks);
    255       fprintf(fd, " \t \t%d\t%d\t%d\t%d\n", s_pages, s_free_blocks, s_used_blocks,
    256               (int) bin->sticky);
    257       bin = bin->next;
    258       *pages += s_pages;
    259       *used_blocks += s_used_blocks;
    260       *free_blocks += s_free_blocks;
    261     }
    262   }
    263 }
    264  
    265 void omPrintBinStats(FILE* fd)
    266 {
    267   int i = OM_MAX_BIN_INDEX, pages=0, used_blocks=0, free_blocks=0;
    268   int pages_p, used_blocks_p, free_blocks_p;
    269   omSpecBin s_bin = om_SpecBin;
    270  
    271   fprintf(fd, " SizeW\tBlocks\tUPages\tFBlocks\tUBlocks\tSticky\n");
    272   fflush(fd);
    273   while (s_bin != NULL || i >= 0)
    274   {
    275     if (s_bin == NULL || (i >= 0 && (unsigned long) om_StaticBin[i].max_blocks < (unsigned long) s_bin->bin->max_blocks))
    276     {
    277        omPrintBinStat(fd, &om_StaticBin[i], 0, &pages_p, &used_blocks_p, &free_blocks_p);
    278        pages += pages_p;
    279        used_blocks += used_blocks_p;
    280        free_blocks += free_blocks_p;
    281 #ifdef OM_HAVE_TRACK
    282        if (om_StaticTrackBin[i].current_page != om_ZeroPage)
    283        {
    284          omPrintBinStat(fd, &om_StaticTrackBin[i], 1, &pages_p, &used_blocks_p, &free_blocks_p);
    285          pages += pages_p;
    286          used_blocks += used_blocks_p;
    287          free_blocks += free_blocks_p;
    288        }
    289 #endif       
    290        i--;
    291     }
    292     else
    293     {
    294       omPrintBinStat(fd, s_bin->bin,0, &pages_p, &used_blocks_p, &free_blocks_p);
    295       pages += pages_p;
    296       used_blocks += used_blocks_p;
    297       free_blocks += free_blocks_p;
    298       s_bin = s_bin->next;
    299     }
    300   }
    301 #ifdef OM_HAVE_TRACK
    302   s_bin = om_SpecTrackBin;
    303   while (s_bin != NULL)
    304   {
    305     omPrintBinStat(fd, s_bin->bin, 0,  &pages_p, &used_blocks_p, &free_blocks_p);
    306     s_bin = s_bin->next;
    307     pages += pages_p;
    308     used_blocks += used_blocks_p;
    309     free_blocks += free_blocks_p;
    310   }
    311 #endif
    312   fprintf(fd, "----------------------------------------\n");
    313   fprintf(fd, "      \t      \t%d\t%d\t%d\n", pages, free_blocks, used_blocks);
    314 }
    315  
     186
    316187/*****************************************************************
    317188 *
     
    401272 
    402273  omBinPage page = from_bin->last_page;
    403   omAssume(to_bin->sticky == 0);
    404274  omAssume(to_bin->sizeW == from_bin->sizeW);
    405275  omAssume(to_bin != from_bin);
    406   omAssume(omIsOnGList(to_bin->next, next, from_bin)
    407            ||
    408            omIsOnGList(from_bin->next, next, to_bin));
    409276
    410277  if (page == NULL) return;
    411278  do
    412279  {
    413     omSetStickyOfPage(page, 0);
     280    omSetTopBinAndStickyOfPage(page, to_bin, to_bin->sticky);
    414281    if (page->prev == NULL) break;
    415282    page = page->prev;
     
    499366
    500367
     368/*****************************************************************
     369 *
     370 * Sticky bins
     371 *
     372 *****************************************************************/
     373omBin om_StickyBins = NULL;
     374omBin omGetStickyBinOfBin(omBin bin)
     375{
     376  omBin new_bin = omAlloc(sizeof(omBin_t));
     377  omAssume(omIsKnownTopBin(bin, 1) && ! omIsStickyBin(bin));
     378  new_bin->sticky = SIZEOF_VOIDP;
     379  new_bin->max_blocks = bin->max_blocks;
     380  new_bin->sizeW = bin->sizeW;
     381  new_bin->next = om_StickyBins;
     382  om_StickyBins = new_bin;
     383  new_bin->last_page = NULL;
     384  new_bin->current_page = om_ZeroPage;
     385#if 0
     386  if (omIsSpecBin(bin))
     387  {
     388    omSpecBin s_bin = omFindInSortedGList(om_SpecBin, next, max_blocks, bin->max_blocks);
     389    omAssume(s_bin != NULL);
     390    if (s_bin != NULL)
     391      s_bin->ref++;
     392  }
     393#endif
     394  return new_bin;
     395}
     396
     397void omMergeStickyBinIntoBin(omBin sticky_bin, omBin into_bin)
     398{
     399  omSpecBin s_bin;
     400  if (! omIsOnGList(om_StickyBins, next, sticky_bin) ||
     401      !sticky_bin->sticky ||
     402      sticky_bin->max_blocks != into_bin->max_blocks ||
     403      sticky_bin == into_bin ||
     404      !omIsKnownTopBin(into_bin, 1) ||
     405      omIsStickyBin(into_bin))
     406  {
     407#ifndef OM_NDEBUG
     408    omReportError(omError_StickyBin, omError_NoError, OM_FLR,
     409                  (! omIsOnGList(om_StickyBins, next, sticky_bin)  ? "unknown sticky_bin" :
     410                   (!sticky_bin->sticky ? "sticky_bin is not sticky" :
     411                    (sticky_bin->max_blocks != into_bin->max_blocks ? "sticky_bin and into_bin have different block sizes" :
     412                     (sticky_bin == into_bin ? "sticky_bin == into_bin" :
     413                      (!omIsKnownTopBin(into_bin, 1) ? "unknown into_bin" :
     414                       (omIsStickyBin(into_bin) ? "into_bin is sticky" :
     415                        "unknown sticky_bin error")))))));
     416#endif
     417    return;
     418  }
     419  omFreeKeptAddrFromBin(sticky_bin);
     420  om_StickyBins = omRemoveFromGList(om_StickyBins, next, sticky_bin);
     421  omMergeStickyPages(into_bin, sticky_bin);
     422
     423#if 0
     424  if (! omIsStaticBin(into_bin))
     425  {
     426    omBin _ibin = into_bin;
     427    omUnGetSpecBin(&_ibin);
     428  }
     429#endif
     430  omFreeSize(sticky_bin, sizeof(omBin_t));
     431#if defined(OM_INTERNAL_DEBUG) && !defined(OM_NDEBUG)
     432  omTestBin(into_bin, 2);
     433#endif 
     434}
    501435 
    502436/*****************************************************************
     
    505439*
    506440*****************************************************************/
     441#ifndef OM_NDEBUG
     442int omIsKnownTopBin(omBin bin, int normal_bin)
     443{
     444  omBin to_check;
     445  omSpecBin s_bin;
     446  int i;
     447 
     448  omAssume(normal_bin == 1 || normal_bin == 0);
     449 
     450#ifdef OM_HAVE_TRACK
     451  if (! normal_bin)
     452  {
     453    to_check = om_StaticTrackBin;
     454    s_bin = om_SpecTrackBin;
     455  }
     456  else
     457#endif
     458  {
     459    omAssume(normal_bin);
     460    to_check = om_StaticBin;
     461    s_bin = om_SpecBin;
     462  }
     463
     464  for (i=0; i<= OM_MAX_BIN_INDEX; i++)
     465  {
     466    if (bin == &(to_check[i]))
     467      return 1;
     468  }
     469 
     470  while (s_bin != NULL)
     471  {
     472    if (bin == s_bin->bin) return 1;
     473    s_bin = s_bin->next;
     474  }
     475  to_check = om_StickyBins;
     476
     477  while (to_check != NULL)
     478  {
     479    if (bin == to_check) return 1;
     480    to_check = to_check->next;
     481  }
     482  return 0;
     483}
     484#endif
     485
    507486unsigned long omGetNewStickyAllBinTag()
    508487{
     
    625604#endif
    626605
     606/*****************************************************************
     607 *
     608 * Statistics
     609 *
     610 *****************************************************************/
     611static void omGetBinStat(omBin bin, int *pages_p, int *used_blocks_p,
     612                          int *free_blocks_p)
     613{
     614  int pages = 0, used_blocks = 0, free_blocks = 0;
     615  int where = 1;
     616 
     617  omBinPage page = bin->last_page;
     618  while (page != NULL)
     619  {
     620    pages++; if (where == 1)
     621    {
     622      used_blocks += omGetUsedBlocksOfPage(page) + 1;
     623      if (bin->max_blocks > 0)
     624        free_blocks += bin->max_blocks - omGetUsedBlocksOfPage(page) -1;
     625    }
     626    else
     627    {
     628      if (bin->max_blocks > 1)
     629        used_blocks += bin->max_blocks;
     630      else
     631        used_blocks++;
     632    }
     633    if (page == bin->current_page) where = -1;
     634    page = page->prev;
     635  }
     636  *pages_p = pages;
     637  *used_blocks_p = used_blocks;
     638  *free_blocks_p = free_blocks;
     639}
     640
     641static void omGetTotalBinStat(omBin bin, int *pages_p, int *used_blocks_p,
     642                               int *free_blocks_p)
     643{
     644  int t_pages = 0, t_used_blocks = 0, t_free_blocks = 0;
     645  int pages = 0, used_blocks = 0, free_blocks = 0;
     646 
     647  while (bin != NULL)
     648  {
     649    omGetBinStat(bin, &pages, &used_blocks, &free_blocks);
     650    t_pages += pages;
     651    t_used_blocks += used_blocks;
     652    t_free_blocks += free_blocks;
     653    if (!omIsStickyBin(bin))
     654      bin = bin->next;
     655    else
     656      bin = NULL;
     657  }
     658  *pages_p = t_pages;
     659  *used_blocks_p = t_used_blocks;
     660  *free_blocks_p = t_free_blocks;
     661}
     662
     663static void omPrintBinStat(FILE * fd, omBin bin, int track, int* pages, int* used_blocks, int* free_blocks)
     664{
     665  if (track)
     666  {
     667    fprintf(fd, "T \t \t");
     668  }
     669  else
     670  {
     671    fprintf(fd, "%s%u\t%ld\t", (omIsStaticNormalBin(bin) ? " " :
     672                                (omIsStickyBin(bin) ? "S" :
     673                                 (omIsTrackBin(bin) ? "T" : "*"))),
     674            bin->sizeW, bin->max_blocks);
     675  }
     676  omGetTotalBinStat(bin, pages, used_blocks, free_blocks);
     677  fprintf(fd, "%d\t%d\t%d\n", *pages, *free_blocks, *used_blocks);
     678  if (bin->next != NULL && !omIsStickyBin(bin))
     679  {
     680    int s_pages, s_free_blocks, s_used_blocks;
     681    while (bin != NULL)
     682    {
     683      omGetBinStat(bin, &s_pages, &s_used_blocks, &s_free_blocks);
     684      fprintf(fd, " \t \t%d\t%d\t%d\t%d\n", s_pages, s_free_blocks, s_used_blocks,
     685              (int) bin->sticky);
     686      bin = bin->next;
     687      *pages += s_pages;
     688      *used_blocks += s_used_blocks;
     689      *free_blocks += s_free_blocks;
     690    }
     691  }
     692}
     693 
     694void omPrintBinStats(FILE* fd)
     695{
     696  int i = OM_MAX_BIN_INDEX, pages=0, used_blocks=0, free_blocks=0;
     697  int pages_p, used_blocks_p, free_blocks_p;
     698  omSpecBin s_bin = om_SpecBin;
     699  omBin sticky;
     700 
     701  fprintf(fd, " SizeW\tBlocks\tUPages\tFBlocks\tUBlocks\tSticky\n");
     702  fflush(fd);
     703  while (s_bin != NULL || i >= 0)
     704  {
     705    if (s_bin == NULL || (i >= 0 && (unsigned long) om_StaticBin[i].max_blocks < (unsigned long) s_bin->bin->max_blocks))
     706    {
     707       omPrintBinStat(fd, &om_StaticBin[i], 0, &pages_p, &used_blocks_p, &free_blocks_p);
     708       pages += pages_p;
     709       used_blocks += used_blocks_p;
     710       free_blocks += free_blocks_p;
     711#ifdef OM_HAVE_TRACK
     712       if (om_StaticTrackBin[i].current_page != om_ZeroPage)
     713       {
     714         omPrintBinStat(fd, &om_StaticTrackBin[i], 1, &pages_p, &used_blocks_p, &free_blocks_p);
     715         pages += pages_p;
     716         used_blocks += used_blocks_p;
     717         free_blocks += free_blocks_p;
     718       }
     719#endif       
     720       i--;
     721    }
     722    else
     723    {
     724      omPrintBinStat(fd, s_bin->bin,0, &pages_p, &used_blocks_p, &free_blocks_p);
     725      pages += pages_p;
     726      used_blocks += used_blocks_p;
     727      free_blocks += free_blocks_p;
     728      s_bin = s_bin->next;
     729    }
     730  }
     731#ifdef OM_HAVE_TRACK
     732  s_bin = om_SpecTrackBin;
     733  while (s_bin != NULL)
     734  {
     735    omPrintBinStat(fd, s_bin->bin, 0,  &pages_p, &used_blocks_p, &free_blocks_p);
     736    s_bin = s_bin->next;
     737    pages += pages_p;
     738    used_blocks += used_blocks_p;
     739    free_blocks += free_blocks_p;
     740  }
     741#endif
     742  sticky = om_StickyBins;
     743  while (sticky != NULL)
     744  {
     745    omPrintBinStat(fd, sticky, 0,  &pages_p, &used_blocks_p, &free_blocks_p);
     746    sticky = sticky->next;
     747    pages += pages_p;
     748    used_blocks += used_blocks_p;
     749    free_blocks += free_blocks_p;
     750  }
     751  fprintf(fd, "----------------------------------------\n");
     752  fprintf(fd, "      \t      \t%d\t%d\t%d\n", pages, free_blocks, used_blocks);
     753}
     754 
    627755static  int omGetUsedBytesOfBin(omBin bin)
    628756{
     
    637765  omSpecBin s_bin = om_SpecBin;
    638766  size_t used = 0;
     767  omBin sticky;
    639768 
    640769  for (; i>=0; i--)
     
    660789#endif
    661790
     791  sticky = om_StickyBins;
     792  while (sticky != NULL)
     793  {
     794    used += omGetUsedBytesOfBin(sticky);
     795    sticky = sticky->next;
     796  }
    662797  return used;
    663798}
  • omalloc/omBin.h

    rff4e34f rf103fb  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omBin.h,v 1.3 2000-08-14 12:26:41 obachman Exp $
     6 *  Version: $Id: omBin.h,v 1.4 2000-10-04 13:12:29 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_BIN_H
    99#define OM_BIN_H
    10 
    11 
    1210
    1311#define omGetAlignedSpecBin(size) _omGetSpecBin(size, 1, 0)
     
    1917void  _omUnGetSpecBin(omBin *bin, int force);
    2018size_t omGetUsedBinBytes();
     19
     20omBin omGetStickyBinOfBin(omBin bin);
     21void omMergeStickyBinIntoBin(omBin sticky_bin, omBin into_bin);
    2122
    2223unsigned long omGetNewStickyBinTag(omBin bin);
     
    3132
    3233void omPrintBinStats(FILE* fd);
     34#define omIsStickyBin(bin) (bin->sticky >= SIZEOF_VOIDP)
    3335
    3436/*BEGINPRIVATE*/
     37#ifndef OM_NDEBUG
     38int omIsKnownTopBin(omBin bin, int normal_bin);
     39#endif
    3540#ifdef OM_HAVE_TRACK
    3641#define omGetSpecTrackBin(size) _omGetSpecBin(size, 0, 1)
     
    4045 ((unsigned long) bin >= ((unsigned long) &om_StaticBin[0]) &&              \
    4146  (unsigned long) bin <= ((unsigned long) &om_StaticBin[OM_MAX_BIN_INDEX]))
    42 #define omIsNormalBin(bin) omIsStaticNormalBin(bin) || omFindInGList(om_SpecBin, next, bin, bin)
     47#define omIsNormalBin(bin) omIsStaticNormalBin(bin) || omFindInGList(om_SpecBin, next, bin, bin) || omIsStickyBin(bin)
     48#define omIsSpecBin(bin) (!omIsStaticNormalBin(bin) && !omIsStickyBin(bin))
    4349
    4450#ifdef OM_HAVE_TRACK
     
    4854#define omIsTrackBin(bin) omIsStaticTrackBin(bin) || omFindInGList(om_SpecTrackBin, next, bin, bin)
    4955#else
     56#define omIsKnownTopBin(bin, normal_bin)  1
    5057#define omIsStaticTrackBin(bin) 0
    5158#define omIsTrackBin(bin)       0
  • omalloc/omDebug.c

    rff4e34f rf103fb  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 7/00
    6  *  Version: $Id: omDebug.c,v 1.11 2000-09-25 12:27:42 obachman Exp $
     6 *  Version: $Id: omDebug.c,v 1.12 2000-10-04 13:12:29 obachman Exp $
    77 *******************************************************************/
    88#include <limits.h>
     9#include <string.h>
    910#include "omConfig.h"
    1011#include "omAlloc.h"
     
    268269
    269270#ifdef OM_INTERNAL_DEBUG
    270   (void) _omCheckAddr(ret, i+1,OM_FUSED|OM_FSIZE,om_Opts.MinCheck, omError_InternalBug, OM_FLR);
     271  (void) _omCheckAddr(ret, (void*)i+1,OM_FUSED|OM_FSIZE,om_Opts.MinCheck, omError_InternalBug, OM_FLR);
    271272#endif
    272273  return ret;
     
    453454    {
    454455      omBin bin = omGetTopBinOfAddr(addr);
    455       if (!omIsStaticNormalBin(bin)) return bin;
     456      if (omIsSpecBin(bin)) return bin;
    456457    }
    457458  }
     
    536537}
    537538
     539void omFreeKeptAddrFromBin(omBin bin)
     540{
     541  void* addr = om_KeptAddr;
     542  void* prev_addr = NULL;
     543  void* next_addr;
     544  omTrackFlags_t flags;
     545 
     546  while (addr != NULL)
     547  {
     548    next_addr = *((void**) addr);
     549    if (omIsBinPageAddr(addr) && omGetTopBinOfAddr(addr) == bin)
     550    {
     551      if (prev_addr != NULL)
     552        *((void**) prev_addr) = next_addr;
     553      else
     554        om_KeptAddr =  next_addr;
     555      if (addr == om_LastKeptAddr)
     556        om_LastKeptAddr = prev_addr;
     557      om_NumberOfKeptAddrs--;
     558#ifdef OM_HAVE_TRACK
     559      if (omIsTrackAddr(addr))
     560      {
     561        omMarkAsFreeTrackAddr(addr, 0, &flags, OM_FLR);
     562        omFreeTrackAddr(addr);
     563      }
     564    else
     565#endif   
     566      __omFree(addr);
     567      addr = next_addr;
     568    }
     569    else
     570    {
     571      prev_addr = addr;
     572      addr = next_addr;
     573    }
     574  }
     575 
     576  addr = om_AlwaysKeptAddrs;
     577  prev_addr = NULL;
     578  while (addr != NULL)
     579  {
     580    next_addr = *((void**) addr);
     581    if (omIsBinPageAddr(addr) && omGetTopBinOfAddr(addr) == bin)
     582    {
     583      if (prev_addr != NULL)
     584        *((void**) prev_addr) = next_addr;
     585      else
     586        om_AlwaysKeptAddrs = next_addr;
     587#ifdef OM_HAVE_TRACK
     588      if (omIsTrackAddr(addr))
     589      {
     590        omMarkAsFreeTrackAddr(addr, 0, &flags, OM_FLR);
     591        omFreeTrackAddr(addr);
     592      }
     593    else
     594#endif   
     595      __omFree(addr);
     596      addr = next_addr;
     597    }
     598    else
     599    {
     600      prev_addr = addr;
     601      addr = next_addr;
     602    }
     603  }
     604}
     605 
    538606void omFreeKeptAddr()
    539607{
     
    541609  omBin bin;
    542610  omTrackFlags_t flags;
     611  void* addr = om_KeptAddr;
    543612
    544613  if (om_LastKeptAddr != NULL)
    545614    *((void**) om_LastKeptAddr) = om_AlwaysKeptAddrs;
    546615 
    547   while (om_KeptAddr != NULL)
    548   {
    549     next = *((void**)om_KeptAddr);
    550     bin = omGetOrigSpecBinOfAddr(om_KeptAddr);
    551 
    552 #ifdef OM_HAVE_TRACK
    553     if (omIsTrackAddr(om_KeptAddr))
    554     {
    555       omMarkAsFreeTrackAddr(om_KeptAddr, 0, &flags, OM_FLR);
    556       omFreeTrackAddr(om_KeptAddr);
    557     }
    558     else
    559 #endif   
    560       __omFree(om_KeptAddr);
    561 
    562     if (bin != NULL) omUnGetSpecBin(&bin);
    563     om_KeptAddr = next;
    564   }
    565616  om_NumberOfKeptAddrs = 0;
    566617  om_LastKeptAddr = NULL;
    567618  om_AlwaysKeptAddrs = NULL;
     619  om_KeptAddr = NULL;
     620 
     621  while (addr != NULL)
     622  {
     623    next = *((void**)addr);
     624    bin = omGetOrigSpecBinOfAddr(addr);
     625
     626#ifdef OM_HAVE_TRACK
     627    if (omIsTrackAddr(addr))
     628    {
     629      omMarkAsFreeTrackAddr(addr, 0, &flags, OM_FLR);
     630      omFreeTrackAddr(addr);
     631    }
     632    else
     633#endif   
     634      __omFree(addr);
     635
     636    addr = next;
     637    if (bin != NULL) omUnGetSpecBin(&bin);
     638  }
    568639}
    569640
  • omalloc/omDebug.h

    rff4e34f rf103fb  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 7/00
    6  *  Version: $Id: omDebug.h,v 1.10 2000-09-18 09:12:14 obachman Exp $
     6 *  Version: $Id: omDebug.h,v 1.11 2000-10-04 13:12:29 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_DEBUG_H
     
    9393
    9494#ifndef OM_NDEBUG
    95 
    96 
    9795void* om_KeptAddr;
    9896void* om_LastKeptAddr;
     
    10199void* om_AlwaysKeptAddrs;
    102100
     101void omFreeKeptAddrFromBin(omBin bin);
    103102/***********************************************************************
    104103 *
     
    117116omError_t omDoCheckBin(omBin bin, int normal_bin, char level,
    118117                       omError_t report, OM_FLR_DECL);
    119 int omIsKnownTopBin(omBin bin, int normal_bin);
    120118void omIterateTroughAddrs(int normal, int track, void (*CallBackUsed)(void*), void (*CallBackFree)(void*));
    121119void omIterateTroughBinAddrs(omBin bin, void (*CallBackUsed)(void*), void (*CallBackFree)(void*));
     
    191189  omAddrCheckReturnError(cond, omError_MemoryCorrupted)
    192190
     191#else
     192#define omFreeKeptAddrFromBin(bin) ((void)0)
    193193#endif /* ! OM_NDEBUG */
    194194/*ENDPRIVATE*/
    195195
     196
    196197#endif /* OM_DEBUG_H */
  • omalloc/omDebugCheck.c

    rff4e34f rf103fb  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omDebugCheck.c,v 1.8 2000-09-25 12:27:42 obachman Exp $
     6 *  Version: $Id: omDebugCheck.c,v 1.9 2000-10-04 13:12:30 obachman Exp $
    77 *******************************************************************/
    88#include <limits.h>
     
    6161  int i = 0;
    6262  omSpecBin s_bin;
     63  omBin sticky;
    6364 
    6465  if (check <= 0) return omError_NoError;
     
    7980  }
    8081
     82  sticky = om_StickyBins;
     83  omCheckReturn(omCheckGList(sticky, next, check, omError_MemoryCorrupted, OM_FLR_VAL));
     84  while (sticky != NULL)
     85  {
     86    omCheckReturn(omDoCheckBin(sticky, 1, check, report, OM_FLR_VAL));
     87    sticky = sticky->next;
     88  }
     89 
    8190#ifdef OM_HAVE_TRACK
    8291  for (i=0; i<= OM_MAX_BIN_INDEX; i++)
     
    233242                         && ((omBin) bin_size) != omGetTopBinOfAddr(addr), omError_WrongBin);
    234243
    235   if (flags & OM_FSIZE && (!(flags & OM_FSLOPPY)  || (size_t) bin_size > 0))
     244  if ((flags & OM_FSIZE) && (!(flags & OM_FSLOPPY)  || (size_t) bin_size > 0))
    236245  {
    237246    size_t size = (size_t) bin_size;
     
    249258 
    250259  omCheckReturnError(!omIsKnownTopBin(bin, normal_bin), omError_UnknownBin);
    251   omCheckReturn(omCheckGList(bin->next, next, level, report, OM_FLR_VAL));
     260  if (! omIsStickyBin(bin))
     261    omCheckReturn(omCheckGList(bin->next, next, level, report, OM_FLR_VAL));
    252262 
    253263  do
     
    273283    if (level <= 1) continue;
    274284   
    275     omCheckReturnCorrupted(omFindInGList(bin->next, next, sticky, bin->sticky));
     285    if (! omIsStickyBin(bin))
     286      omCheckReturnCorrupted(omFindInGList(bin->next, next, sticky, bin->sticky));
    276287    omCheckReturn(omCheckGList(bin->last_page, prev, level-1, report, OM_FLR_VAL));
    277288    page = omGListLast(bin->last_page, prev);
     
    293304      omCheckReturnCorrupted(page->prev != NULL && page->prev->next != page);
    294305     
    295       omCheckReturnCorrupted(omGetStickyOfPage(page) != bin->sticky);
     306      omCheckReturnCorrupted(omGetStickyOfPage(page) != bin->sticky && bin->sticky < SIZEOF_VOIDP);
    296307      omCheckReturnCorrupted(omGetBinOfPage(page) != bin);
    297308     
    298       if (! bin->sticky)
     309      if (where == -1)
    299310      {
    300         if (where == -1)
     311        /* we are at the left of current_page,
     312           i.e., page is empty */
     313        omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) != 0 || page->current != NULL);
     314      }
     315      else
     316      {
     317        if (page == bin->current_page)
    301318        {
    302           /* we are at the left of current_page,
    303              i.e., page is empty */
    304           omCheckReturnCorrupted(omGetUsedBlocksOfPage(page) != 0 || page->current != NULL);
     319          where = -1;
    305320        }
    306321        else
    307322        {
    308           if (page == bin->current_page)
    309           {
    310             where = -1;
    311           }
    312           else
    313           {
    314             /* we are at the right of current_page,
    315                i.e., page is neither full nor empty */
    316             omCheckReturnCorrupted(page->current == NULL ||
    317                                    omGetUsedBlocksOfPage(page) == bin->max_blocks - 1);
    318           }
     323          /* we are at the right of current_page,
     324             i.e., page is neither full nor empty */
     325          omCheckReturnCorrupted(page->current == NULL ||
     326                                 omGetUsedBlocksOfPage(page) == bin->max_blocks - 1);
    319327        }
    320328      }
    321329      page = page->prev;
    322330    }   /* while (page != NULL) */
    323   } while ((bin = bin->next) != NULL);
     331  } while (!omIsStickyBin(bin) && ((bin = bin->next) != NULL));
    324332 
    325333  return omError_NoError;
    326334}
    327335 
    328 int omIsKnownTopBin(omBin bin, int normal_bin)
    329 {
    330   omBin to_check;
    331   omSpecBin s_bin;
    332   int i;
    333  
    334   omAssume(normal_bin == 1 || normal_bin == 0);
    335  
    336 #ifdef OM_HAVE_TRACK
    337   if (! normal_bin)
    338   {
    339     to_check = om_StaticTrackBin;
    340     s_bin = om_SpecTrackBin;
    341   }
    342   else
    343 #endif
    344   {
    345     omAssume(normal_bin);
    346     to_check = om_StaticBin;
    347     s_bin = om_SpecBin;
    348   }
    349 
    350   for (i=0; i<= OM_MAX_BIN_INDEX; i++)
    351   {
    352     if (bin == &(to_check[i]))
    353       return 1;
    354   }
    355  
    356   while (s_bin != NULL)
    357   {
    358     if (bin == s_bin->bin) return 1;
    359     s_bin = s_bin->next;
    360   }
    361   return 0;
    362 }
    363336
    364337static omError_t omDoCheckBinPage(omBinPage page, int normal_page, int level,
     
    510483      page = page->prev;
    511484    }
    512     bin = bin->next;
     485    if (omIsStickyBin(bin))
     486      bin = NULL;
     487    else
     488      bin = bin->next;
    513489  } while (bin != NULL);
    514490 
     
    519495  int i;
    520496  omSpecBin s_bin;
     497  omBin sticky;
    521498
    522499  if (normal)
     
    549526  }
    550527#endif
     528  sticky = om_StickyBins;
     529  while (sticky != NULL)
     530  {
     531    omIterateTroughBinAddrs(sticky, CallBackUsed, CallBackFree);
     532    sticky = sticky->next;
     533  }
    551534}
    552535
  • omalloc/omDebugTrack.c

    rff4e34f rf103fb  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omDebugTrack.c,v 1.10 2000-09-20 11:52:31 obachman Exp $
     6 *  Version: $Id: omDebugTrack.c,v 1.11 2000-10-04 13:12:30 obachman Exp $
    77 *******************************************************************/
    88#include <limits.h>
     9#include <string.h>
    910#include "omConfig.h"
    1011#include "omDerivedConfig.h"
     
    326327    if (track > 2)
    327328    {
    328       d_addr->bin_size = (flags & OM_FBIN ? bin_size : (void*) o_size);
     329      if (flags & OM_FBIN && ((omBin) bin_size)->sticky)
     330      {
     331        d_addr->bin_size = (void*)(((omBin) bin_size)->sizeW<<LOG_SIZEOF_LONG);
     332        d_addr->flags &= ~OM_FBIN;
     333        d_addr->flags |= OM_FSIZE;
     334      }
     335      else
     336        d_addr->bin_size = (flags & OM_FBIN ? bin_size : (void*) o_size);
    329337      omAssume(OM_ALIGN_SIZE((size_t)d_addr->bin_size) == (size_t) d_addr->bin_size);
    330338
     
    494502     
    495503    omAddrCheckReturnError((flags & OM_FBINADDR) && !((d_addr->flags & OM_FBIN) || ((size_t) d_addr->bin_size <= OM_MAX_BLOCK_SIZE)), omError_NotBinAddr);
    496      
    497     omAddrCheckReturnError((flags & OM_FBIN) && ( !(d_addr->flags & OM_FBIN) || d_addr->bin_size != bin_size),omError_WrongBin);
    498     if (flags & OM_FSIZE)
    499     {
    500       if (d_addr->flags & OM_FSIZE)
    501         omAddrCheckReturnError((size_t) d_addr->bin_size != OM_ALIGN_SIZE((size_t) bin_size), omError_WrongSize);
     504     
     505    if (flags & OM_FBIN)
     506    {
     507      if (d_addr->flags & OM_FBIN)
     508        omAddrCheckReturnError(((omBin) d_addr->bin_size)->sizeW != ((omBin) bin_size)->sizeW, omError_WrongBin);
    502509      else
    503         omAddrCheckReturnError(omTrackAddr_2_OutSize(d_addr) < (size_t) bin_size, omError_WrongSize);
    504     }
    505 
     510        omAddrCheckReturnError((((omBin) bin_size)->sizeW << LOG_SIZEOF_LONG) != OM_ALIGN_SIZE((size_t) d_addr->bin_size), omError_WrongBin);
     511    }
     512    else if (flags & OM_FSIZE)
     513    {
     514      if (d_addr->flags & OM_FBIN)
     515      {
     516        omAddrCheckReturnError((((omBin) d_addr->bin_size)->sizeW << LOG_SIZEOF_LONG) < ((size_t) bin_size), omError_WrongSize);
     517      }
     518      else
     519      {
     520        omAddrCheckReturnError((size_t) d_addr->bin_size < (size_t) bin_size, omError_WrongSize);
     521      }
     522    }
     523 
    506524    omAddrCheckReturnError(omCheckPattern(omTrackAddr_2_FrontPattern(d_addr), OM_FRONT_PATTERN,omTrackAddr_2_SizeOfFrontPattern(d_addr)),omError_FrontPattern);
    507525    omAddrCheckReturnError(omCheckPattern(omTrackAddr_2_BackPattern(d_addr), OM_BACK_PATTERN,omTrackAddr_2_SizeOfBackPattern(d_addr)),omError_BackPattern);
     
    628646  {
    629647    omBin bin = (omBin) d_addr->bin_size;
    630     if (! omIsStaticNormalBin(bin))
    631       return bin;
     648    if (omIsSpecBin(bin)) return bin;
    632649  }
    633650  return NULL;
  • omalloc/omError.c

    rff4e34f rf103fb  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omError.c,v 1.6 2000-09-25 12:27:43 obachman Exp $
     6 *  Version: $Id: omError.c,v 1.7 2000-10-04 13:12:30 obachman Exp $
    77 *******************************************************************/
    88
     
    4646  {omError_FreePattern,                 "omError_FreePattern",                 "written into freed memory"},
    4747  {omError_NotString,                   "omError_NotString",                   "string not null terminated"},
     48  {omError_StickyBin,                   "omError_StickyBin",                   "wrong handling of sticky bins"},
    4849 
    4950  {omError_MaxError, NULL} /* this needs to be the last entry */
  • omalloc/omError.h

    rff4e34f rf103fb  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omError.h,v 1.6 2000-09-18 09:12:15 obachman Exp $
     6 *  Version: $Id: omError.h,v 1.7 2000-10-04 13:12:30 obachman Exp $
    77 *******************************************************************/
    88#ifndef OM_ERROR_H
     
    4040  omError_FrontPattern,
    4141  omError_NotString,
     42  omError_StickyBin,
    4243  omError_MaxError
    4344};
  • omalloc/omInline.h

    rff4e34f rf103fb  
    55 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    66 *  Created: 11/99
    7  *  Version: $Id: omInline.h,v 1.4 2000-08-16 16:08:33 obachman Exp $
     7 *  Version: $Id: omInline.h,v 1.5 2000-10-04 13:12:31 obachman Exp $
    88 *******************************************************************/
    99#if defined(OM_INLINE) || defined(OM_ALLOC_C)
     
    1616  unsigned long sticky = omGetStickyOfPage(page);
    1717  omBin bin = omGetTopBinOfPage(page);
    18  
    19   while (bin->sticky != sticky && bin->next != NULL)
    20   {
    21     bin = bin->next;
     18
     19  if (! omIsStickyBin(bin))
     20  {
     21    while (bin->sticky != sticky && bin->next != NULL)
     22    {
     23      bin = bin->next;
     24    }
    2225  }
    2326  return bin;
  • omalloc/omList.c

    rff4e34f rf103fb  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omList.c,v 1.5 2000-08-14 12:26:46 obachman Exp $
     6 *  Version: $Id: omList.c,v 1.6 2000-10-04 13:12:31 obachman Exp $
    77 *******************************************************************/
    88#include "omConfig.h"
     
    177177omError_t _omCheckList(void* list, int next, int level, omError_t report, OM_FLR_DECL)
    178178{
    179   if (level <= 1) return omError_NoError;
     179  if (level < 1) return omError_NoError;
    180180 
    181181  if (level == 1)
  • omalloc/omRet2Info.c

    rff4e34f rf103fb  
    44 *  Author:  obachman (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omRet2Info.c,v 1.7 2000-09-18 09:12:16 obachman Exp $
     6 *  Version: $Id: omRet2Info.c,v 1.8 2000-10-04 13:12:31 obachman Exp $
    77 *******************************************************************/
    88#include <stdio.h>
     
    244244#endif
    245245#ifdef OM_TRACK_RETURN
    246     fprintf(fd," ra=%p");
     246    fprintf(fd," ra=%p", r);
    247247#endif
    248248
  • omalloc/omtTest.c

    rff4e34f rf103fb  
    274274}
    275275
     276omBin omtGetStickyBin(omBin bin)
     277{
     278  omBin sticky_bin = omFindInGList(om_StickyBins, next, max_blocks, bin->max_blocks);
     279  if (sticky_bin == NULL)
     280    sticky_bin = omGetStickyBinOfBin(bin);
     281  return sticky_bin;
     282}
     283
     284void omtMergeStickyBins(omMemCell cell, int n)
     285{
     286  int i;
     287  omBin bin;
     288 
     289  for (i=0; i<n; i++)
     290  {
     291    if (cell[i].orig_bin != NULL)
     292    {
     293      if (omIsOnGList(om_StickyBins, next, cell[i].bin))
     294        omMergeStickyBinIntoBin(cell[i].bin, cell[i].orig_bin);
     295
     296      cell[i].bin = cell[i].orig_bin;
     297      cell[i].orig_bin = NULL;
     298    }
     299  }
     300 
     301  bin = om_StickyBins;
     302  while (bin != NULL)
     303  {
     304    if (bin->current_page == om_ZeroPage)
     305    {
     306      omBin next_bin = bin->next;
     307      om_StickyBins = omRemoveFromGList(om_StickyBins, next, bin);
     308      __omFreeBinAddr(bin);
     309      bin = next_bin;
     310    }
     311    else
     312    {
     313      bin = bin->next;
     314    }
     315  }
     316}
     317
     318 
    276319void my_exit()
    277320{
     
    351394      }
    352395#endif
     396      omtMergeStickyBins(cells, n_cells);
    353397      while (i< n_cells)
    354398      {
     
    357401      }
    358402      omFreeKeptAddr();
     403      omtMergeStickyBins(cells, -1);
    359404      omPrintStats(stdout);
    360405      omPrintInfo(stdout);
  • omalloc/omtTest.h

    rff4e34f rf103fb  
    99
    1010// #define MAX_CELLS  500000   
     11// #define MAX_CELLS     100000
    1112#define MAX_CELLS     100000
    12 // #define MAX_CELLS     1000
    1313#define KEEP_ADDR     100
    1414#define END_CHECK_LEVEL 5
     
    2626  omBin bin;
    2727  unsigned long spec;
     28  omBin orig_bin;
    2829};
    2930
     
    4546#endif
    4647
     48#define IS_STICKY_BIN(spec) (spec & 1)
     49// #define IS_STICKY_BIN(spec) (0)
    4750#define GET_SIZE(spec)      (spec & ((1 << 14) -1))
    4851#define SET_SIZE(spec, size) spec = ((spec & ~((1 << 14) -1)) | (size))
     
    110113void InitCellAddrContent(omMemCell cell);
    111114int omtTestErrors();
     115omBin omtGetStickyBin(omBin bin);
    112116
    113117#if CHECK_LEVEL > 0
  • omalloc/omtTestAlloc.c

    rff4e34f rf103fb  
    44 *  Author:  obachman@mathematik.uni-kl.de (Olaf Bachmann)
    55 *  Created: 11/99
    6  *  Version: $Id: omtTestAlloc.c,v 1.7 2000-09-18 09:18:26 obachman Exp $
     6 *  Version: $Id: omtTestAlloc.c,v 1.8 2000-10-04 13:12:32 obachman Exp $
    77 *******************************************************************/
    88#include "omtTest.h"
     
    3636  void* addr;
    3737  omBin bin = NULL;
     38  omBin orig_bin = NULL;
    3839
    3940  if (IS_BIN(spec) && (size <= OM_MAX_BLOCK_SIZE || IS_SPEC_BIN(spec)))
     
    4445        bin = omGetAlignedSpecBin(size);
    4546      else
    46         bin = omGetSpecBin(size); 
     47        bin = omGetSpecBin(size);
    4748    }
    4849    else
     
    5253      else
    5354        bin = omSmallSize2Bin(size);
     55    }
     56   
     57    if (IS_STICKY_BIN(spec))
     58    {
     59      orig_bin = bin;
     60      bin = omtGetStickyBin(bin);
    5461    }
    5562   
     
    118125  cell->addr = addr;
    119126  cell->bin = bin;
     127  cell->orig_bin = orig_bin;
    120128  cell->spec = spec;
    121129
     
    130138  unsigned long spec = cell->spec;
    131139  omBin bin = cell->bin;
     140  omBin orig_bin = cell->orig_bin;
    132141  size_t size = GET_SIZE(spec);
    133142
     
    156165 
    157166  if (bin != NULL && IS_SPEC_BIN(spec))
    158     omUnGetSpecBin(&bin);
     167  {
     168    if (orig_bin != NULL)
     169      omUnGetSpecBin(&orig_bin);
     170    else
     171      omUnGetSpecBin(&bin);
     172  }
    159173
    160174  cell->addr = NULL;
    161175  cell->spec = 0;
    162176  cell->bin = NULL;
     177  cell->orig_bin = NULL;
    163178}
    164179
     
    168183  int old_spec = cell->spec;
    169184  omBin old_bin = cell->bin;
     185  omBin old_orig_bin = cell->orig_bin;
    170186  size_t old_size = GET_SIZE(old_spec);
    171187  void* new_addr;
    172188  omBin new_bin = NULL;
     189  omBin new_orig_bin = NULL;
    173190  size_t new_size = GET_SIZE(new_spec);
    174191  size_t real_old_size = omSizeOfAddr(old_addr);
     
    194211        new_bin = omSmallSize2Bin(new_size);
    195212    }
     213
     214    if (IS_STICKY_BIN(new_spec))
     215    {
     216      new_orig_bin = new_bin;
     217      new_bin = omtGetStickyBin(new_bin);
     218    }
    196219       
    197220    if (IS_INLINE(new_spec))
     
    294317
    295318  if (old_bin != NULL && IS_SPEC_BIN(old_spec))
     319  {
     320    if (old_orig_bin != NULL)
     321      omUnGetSpecBin(&old_orig_bin);
     322    else
    296323      omUnGetSpecBin(&old_bin);
     324  }
    297325
    298326  new_size = omSizeOfAddr(new_addr);
     
    312340  cell->spec = new_spec;
    313341  cell->bin = new_bin;
     342  cell->orig_bin = new_orig_bin;
    314343  InitCellAddrContent(cell);
    315344  omtTestDebug(cell);
  • omalloc/omtTestError.c

    rff4e34f rf103fb  
    124124              spec.MinTrack = 3;
    125125              spec.NotIsBin = 1;
     126              spec.MinSize = 2;
    126127              cell = omFindCell(spec);
    127128              if (cell != NULL)
     
    387388#endif
    388389          omStrDup(NULL);
    389         }
     390          break;
     391        }
     392
     393        case omError_StickyBin:
     394        {
     395          omMergeStickyBinIntoBin(NULL, NULL);
     396          break;
     397        }
     398         
    390399        default:
    391400          printf("No Error test implemented\n");
Note: See TracChangeset for help on using the changeset viewer.