pike.git/
src/
stralloc.c
Branch:
Tag:
Non-build tags
All tags
No tags
2005-01-14
2005-01-14 13:43:06 by Henrik Grubbström (Grubba) <grubba@grubba.org>
1bfe77d04e3f598b0ff68b8e0ff9a1e258325bcd (
27
lines) (+
21
/-
6
)
[
Show
|
Annotate
]
Branch:
7.9
rehash_string_backwards() is now recursive no more.
Rev: src/stralloc.c:1.193
2:
|| 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.
192
2004
/
11
/14
18
:
30
:
40
mast
Exp $
+
|| $Id: stralloc.c,v 1.
193
2005
/
01
/14
13
:
43
:
06
grubba
Exp $
*/ #include "global.h"
472:
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;