diff options
author | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 2003-02-11 13:49:32 +0000 |
---|---|---|
committer | Mikael Djurfeldt <djurfeldt@nada.kth.se> | 2003-02-11 13:49:32 +0000 |
commit | f59a096e597787d21d1aabad8c3b24dca6989670 (patch) | |
tree | 1b28bb201b2770ec731cdc18643aeede093284cb /libguile/weaks.c | |
parent | 4b612c5be760a21848ac2ca1804459dc0148a42b (diff) | |
download | guile-f59a096e597787d21d1aabad8c3b24dca6989670.tar.gz |
* hashtab.c (scm_vector_to_hash_table,
scm_c_make_resizing_hash_table, scm_make_hash_table): New
functions.
(scm_hash_fn_get_handle, scm_hash_fn_create_handle_x): Made thread
safe and handle resizing tables.
* weaks.c (scm_make_weak_key_hash_table,
scm_make_weak_value_hash_table, scm_make_doubly_weak_hash_table):
Size argument made optional. Return resizable table if not
specified.
* boot-9.scm (make-hash-table): Turned primitive.
Diffstat (limited to 'libguile/weaks.c')
-rw-r--r-- | libguile/weaks.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libguile/weaks.c b/libguile/weaks.c index 9c34a645f..db8af4ab3 100644 --- a/libguile/weaks.c +++ b/libguile/weaks.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1998,2000,2001 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1998,2000,2001, 2003 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +45,7 @@ #include "libguile/_scm.h" #include "libguile/vectors.h" #include "libguile/lang.h" +#include "libguile/hashtab.h" #include "libguile/validate.h" #include "libguile/weaks.h" @@ -169,7 +170,7 @@ SCM_DEFINE (scm_weak_vector_p, "weak-vector?", 1, 0, 0, -SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 1, 0, 0, +SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 0, 1, 0, (SCM size), "@deffnx {Scheme Procedure} make-weak-value-hash-table size\n" "@deffnx {Scheme Procedure} make-doubly-weak-hash-table size\n" @@ -181,18 +182,26 @@ SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 1, 0, 0, "would modify regular hash tables. (@pxref{Hash Tables})") #define FUNC_NAME s_scm_make_weak_key_hash_table { - return allocate_weak_vector (1, size, SCM_EOL, FUNC_NAME); + if (SCM_UNBNDP (size)) + return scm_vector_to_hash_table (allocate_weak_vector (1, SCM_MAKINUM (37), + SCM_EOL, FUNC_NAME)); + else + return allocate_weak_vector (1, size, SCM_EOL, FUNC_NAME); } #undef FUNC_NAME -SCM_DEFINE (scm_make_weak_value_hash_table, "make-weak-value-hash-table", 1, 0, 0, +SCM_DEFINE (scm_make_weak_value_hash_table, "make-weak-value-hash-table", 0, 1, 0, (SCM size), "Return a hash table with weak values with @var{size} buckets.\n" "(@pxref{Hash Tables})") #define FUNC_NAME s_scm_make_weak_value_hash_table { - return allocate_weak_vector (2, size, SCM_EOL, FUNC_NAME); + if (SCM_UNBNDP (size)) + return scm_vector_to_hash_table (allocate_weak_vector (2, SCM_MAKINUM (37), + SCM_EOL, FUNC_NAME)); + else + return allocate_weak_vector (2, size, SCM_EOL, FUNC_NAME); } #undef FUNC_NAME @@ -203,7 +212,11 @@ SCM_DEFINE (scm_make_doubly_weak_hash_table, "make-doubly-weak-hash-table", 1, 0 "buckets. (@pxref{Hash Tables})") #define FUNC_NAME s_scm_make_doubly_weak_hash_table { - return allocate_weak_vector (3, size, SCM_EOL, FUNC_NAME); + if (SCM_UNBNDP (size)) + return scm_vector_to_hash_table (allocate_weak_vector (3, SCM_MAKINUM (37), + SCM_EOL, FUNC_NAME)); + else + return allocate_weak_vector (3, size, SCM_EOL, FUNC_NAME); } #undef FUNC_NAME |