pike.git / src / stralloc.c

version» Context lines:

pike.git/src/stralloc.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: stralloc.c,v 1.166 2004/09/27 21:37:13 mast Exp $ + || $Id: stralloc.c,v 1.167 2005/01/14 14:27:27 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "dynamic_buffer.h"   #include "pike_macros.h"   #include "pike_memory.h"   #include "pike_error.h"   #include "gc.h"
pike.git/src/stralloc.c:17:   #include "bignum.h"   #include "interpret.h"   #include "block_alloc.h"   #include "operators.h"      #include <errno.h>   #include <float.h>   #include <ctype.h>   #include <math.h>    - RCSID("$Id: stralloc.c,v 1.166 2004/09/27 21:37:13 mast Exp $"); + RCSID("$Id: stralloc.c,v 1.167 2005/01/14 14:27:27 grubba Exp $");      /* #define STRALLOC_USE_PRIMES */      #ifdef STRALLOC_USE_PRIMES      #define SET_HSIZE(X) htable_size=hashprimes[(X)]   #define HMODULO(X) ((X) % htable_size)      #else   
pike.git/src/stralloc.c:454:    }   #endif    }    return 0; /* not found */   }      /*** rehash ***/      static void rehash_string_backwards(struct pike_string *s)   { -  ptrdiff_t h; +  struct pike_string *prev = NULL; +  struct pike_string *next; +     if(!s) return; -  rehash_string_backwards(s->next); -  h = HMODULO(s->hval); -  s->next=base_table[h]; -  base_table[h]=s; +  +  /* Reverse the hash list. */ +  while ((next = s->next)) { +  s->next = prev; +  prev = s; +  s = next;    } -  +  s->next = prev;    -  +  /* Rehash the strings for this list. */ +  do { +  ptrdiff_t h = HMODULO(s->hval); +  next = s->next; +  s->next = base_table[h]; +  base_table[h] = s; +  } while ((s = next)); + } +    static void stralloc_rehash(void)   {    int h,old;    struct pike_string **old_base;       old=htable_size;    old_base=base_table;      #ifdef PIKE_RUN_UNLOCKED    mt_lock(bucket_locks);