pike.git/
src/
mapping.c
Branch:
Tag:
Non-build tags
All tags
No tags
2000-02-04
2000-02-04 20:16:18 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
1f342fdc4e64345d4773267f314cb4d2a4d7a0a0 (
55
lines) (+
14
/-
41
)
[
Show
|
Annotate
]
Branch:
7.9
another mapping bug bites the dust
Rev: src/mapping.c:1.61
Rev: src/testsuite.in:1.267
5:
\*/ /**/ #include "global.h"
-
RCSID("$Id: mapping.c,v 1.
60
2000/02/04
19
:
25
:
10
hubbe Exp $");
+
RCSID("$Id: mapping.c,v 1.
61
2000/02/04
20
:
16
:
16
hubbe Exp $");
#include "main.h" #include "object.h" #include "mapping.h"
29:
struct mapping *first_mapping;
+
#define unlink_mapping_data(M) do{ \
+
struct mapping_data *md_=(M); \
+
if(md_->hardlinks) { md_->hardlinks--; md_->valrefs--; } \
+
free_mapping_data(M); \
+
}while(0)
+
+
#define MD_KEYPAIRS(MD, HSIZE) \ ( (struct keypair *)DO_ALIGN( (long) (((struct mapping_data *)(MD))->hash + HSIZE), ALIGNOF(struct keypair)) )
47:
\ FREE_PROT(m); \ \
-
if(m->data->hardlinks) \
-
{ \
-
m->data->hardlinks--; \
-
m->data->valrefs--; \
-
} \
-
free
_mapping_data(m->data);
\
+
unlink
_mapping_data(m->data); \
\ if(m->prev) \ m->prev->next = m->next; \
305:
for(e=0;e<md->hashsize;e++) mapping_rehash_backwards_good(new_md, md->hash[e]);
-
if(md->hardlinks)
-
{
-
md->hardlinks--;
-
md->valrefs--;
-
}
-
free
_mapping_data(md);
+
unlink
_mapping_data(md);
}else{ /* evil */ for(e=0;e<md->hashsize;e++)
1851:
if(gc_do_free(m)) { add_ref(m);
-
md=m->data;
-
-
/* no locking required
-
*
-
* FIXME: is it possible that md->refs might not be zero here?
-
* for now I will assume it is not possible...
-
*/
-
for(e=0;e<md->hashsize;e++)
-
{
-
k=md->hash[e];
-
while(k)
-
{
-
free
_
svalue(&k->ind);
-
free
_
svalue
(
&k
->
val
);
-
-
if(k
->
next)
-
{
-
k
=
k->next;
-
} else {
-
k->next=md->free
_
list
;
-
md
->
free_list=md
->
hash[e]
;
-
md->hash[e]=0;
-
break;
-
}
-
}
-
}
-
md->size=0;
-
+
unlink
_
mapping
_
data
(
m
->
data
);
+
m
->
data
=
&empty
_
data
;
+
m
->
data
->
refs++
;
next=m->next; free_mapping(m);