diff options
author | Marius Vollmer <mvo@zagadka.de> | 2001-05-20 19:31:58 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2001-05-20 19:31:58 +0000 |
commit | 25c507d9a2fec70c481801259a96c1d5eec52ef6 (patch) | |
tree | 8d66f73202379c5df18f46ce5f8b35aefa11afd1 /libguile/symbols.c | |
parent | 08045107a0eea3871b9b98a5cca41988f3ef9c05 (diff) | |
download | guile-25c507d9a2fec70c481801259a96c1d5eec52ef6.tar.gz |
(scm_mem2symbol): Call `scm_must_strndup' instead of
`duplicate_string'. Do not use an indirect cell, store symbol
directly in collision list of hash table.
(duplicate_string): Removed.
Diffstat (limited to 'libguile/symbols.c')
-rw-r--r-- | libguile/symbols.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/libguile/symbols.c b/libguile/symbols.c index 45f5ee982..f78ece091 100644 --- a/libguile/symbols.c +++ b/libguile/symbols.c @@ -82,17 +82,6 @@ SCM_DEFINE (scm_sys_symbols, "%symbols", 0, 0, 0, -static char * -duplicate_string (const char * src, unsigned long length) -{ - char * dst = scm_must_malloc (length + 1, "duplicate_string"); - memcpy (dst, src, length); - dst[length] = 0; - return dst; -} - - - /* {Symbols} */ @@ -110,8 +99,9 @@ scm_mem2symbol (const char *name, scm_sizet len) for (l = SCM_VELTS (symbols) [hash]; !SCM_NULLP (l); l = SCM_CDR (l)) { - SCM sym = SCM_CAAR (l); - if (SCM_SYMBOL_HASH (sym) == raw_hash && SCM_SYMBOL_LENGTH (sym) == len) + SCM sym = SCM_CAR (l); + if (SCM_SYMBOL_HASH (sym) == raw_hash + && SCM_SYMBOL_LENGTH (sym) == len) { char *chrs = SCM_SYMBOL_CHARS (sym); scm_sizet i = len; @@ -134,18 +124,16 @@ scm_mem2symbol (const char *name, scm_sizet len) /* The symbol was not found - create it. */ SCM symbol; - SCM cell; SCM slot; SCM_NEWCELL2 (symbol); - SCM_SET_SYMBOL_CHARS (symbol, duplicate_string (name, len)); + SCM_SET_SYMBOL_CHARS (symbol, scm_must_strndup (name, len)); SCM_SET_SYMBOL_HASH (symbol, raw_hash); SCM_SET_PROP_SLOTS (symbol, scm_cons (SCM_BOOL_F, SCM_EOL)); SCM_SET_SYMBOL_LENGTH (symbol, (long) len); - cell = scm_cons (symbol, SCM_UNDEFINED); slot = SCM_VELTS (symbols) [hash]; - SCM_VELTS (symbols) [hash] = scm_cons (cell, slot); + SCM_VELTS (symbols) [hash] = scm_cons (symbol, slot); return symbol; } |