From 2e19ebfe01a674257f2722f1bc9c6389364efd4e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 10 May 2005 06:08:57 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/hash.c | 20 ++++++++++---------- ase/stx/makefile.in | 2 +- ase/stx/stx.c | 5 ++++- ase/stx/stx.h | 3 ++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ase/stx/hash.c b/ase/stx/hash.c index 423abfd3..a4c8f9b7 100644 --- a/ase/stx/hash.c +++ b/ase/stx/hash.c @@ -1,16 +1,18 @@ /* - * $Id: hash.c,v 1.3 2005-05-10 06:02:19 bacon Exp $ + * $Id: hash.c,v 1.4 2005-05-10 06:08:57 bacon Exp $ */ #include +#include +#include xp_stx_word_t xp_stx_new_link ( xp_stx_t* stx, xp_stx_word_t key, xp_stx_word_t value) { xp_stx_word_t x; - x = xp_stx_alloc_object (3); - XP_STX_CLASS(stx,x) = hash_lookup(stx, XP_STX_TEXT("Link")); + x = xp_stx_alloc_object (stx, 3); + XP_STX_CLASS(stx,x) = stx->link_class; XP_STX_AT(stx,x,0) = key; XP_STX_AT(stx,x,1) = value; /* XP_STX_AT(stx,x,2) = stx->nil; */ @@ -23,12 +25,12 @@ xp_stx_word_t xp_stx_hash_lookup ( xp_stx_t* stx, xp_stx_word_t table, xp_stx_word_t hash, xp_stx_word_t key) { - xp_stx_word_t harr, link, next; + xp_stx_word_t harr, link; xp_assert (XP_STX_TYPE(stx,table) == XP_STX_INDEXED); harr = XP_STX_AT(stx,table,0); - hash = link % XP_STX_SIZE(stx,table); + hash = hash % XP_STX_SIZE(stx,table); link = XP_STX_AT(stx,harr,hash); while (link != stx->nil) { @@ -48,12 +50,11 @@ void xp_stx_hash_insert ( xp_assert (XP_STX_TYPE(stx,table) == XP_STX_INDEXED); harr = XP_STX_AT(stx,table,0); - hash = link % XP_STX_SIZE(stx,table); + hash = hash % XP_STX_SIZE(stx,table); link = XP_STX_AT(stx,harr,hash); if (link == stx->nil) { - new = xp_stx_new_link (stx, key, value); - XP_STX_AT(stx,harr,hash) = new; + XP_STX_AT(stx,harr,hash) = xp_stx_new_link (stx, key, value); } else { for (;;) { @@ -64,8 +65,7 @@ void xp_stx_hash_insert ( next = XP_STX_AT(stx,link,2); if (next == stx->nil) { - new = xp_stx_new_link (stx, key, value); - XP_STX_AT(stx,link,2) = new; + XP_STX_AT(stx,link,2) = xp_stx_new_link (stx, key, value); break; } diff --git a/ase/stx/makefile.in b/ase/stx/makefile.in index c269860e..781fe85e 100644 --- a/ase/stx/makefile.in +++ b/ase/stx/makefile.in @@ -1,4 +1,4 @@ -SRCS = stx.c memory.c object.c +SRCS = stx.c memory.c object.c hash.c OBJS = $(SRCS:.c=.o) OUT = libxpstx.a diff --git a/ase/stx/stx.c b/ase/stx/stx.c index 75d8a8d0..6fe8bc8d 100644 --- a/ase/stx/stx.c +++ b/ase/stx/stx.c @@ -1,5 +1,5 @@ /* - * $Id: stx.c,v 1.5 2005-05-08 15:22:45 bacon Exp $ + * $Id: stx.c,v 1.6 2005-05-10 06:08:57 bacon Exp $ */ #include @@ -26,6 +26,9 @@ xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_stx_word_t capacity) stx->true = XP_STX_TRUE; stx->false = XP_STX_FALSE; + stx->link_class = XP_STX_NIL; + stx->symbol_table = XP_STX_NIL; + return stx; } diff --git a/ase/stx/stx.h b/ase/stx/stx.h index 4a4b1ac3..6157ea9c 100644 --- a/ase/stx/stx.h +++ b/ase/stx/stx.h @@ -1,5 +1,5 @@ /* - * $Id: stx.h,v 1.6 2005-05-10 06:02:19 bacon Exp $ + * $Id: stx.h,v 1.7 2005-05-10 06:08:57 bacon Exp $ */ #ifndef _XP_STX_STX_H_ @@ -69,6 +69,7 @@ struct xp_stx_t xp_stx_word_t nil; xp_stx_word_t true; xp_stx_word_t false; + xp_stx_word_t link_class; xp_stx_word_t symbol_table; xp_bool_t __malloced;