summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-12-04 06:31:19 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-12-04 06:31:19 -0800
commit4a8722ce9fcbb66abe2bd304e5a4bad03d842821 (patch)
tree85771680aa329b5436a3916d89bbdc34a9328c8b /hash.c
parent507c6c1516233cb565142a71176bc0d3a246d5b4 (diff)
downloadtxr-4a8722ce9fcbb66abe2bd304e5a4bad03d842821.tar.gz
txr-4a8722ce9fcbb66abe2bd304e5a4bad03d842821.tar.bz2
txr-4a8722ce9fcbb66abe2bd304e5a4bad03d842821.zip
args: redesign args extractor to just use array.
* args.c (struct args_bool_key): Structure moved to header file. (struct args_bool_ctx): One more piece of context information, the array size. (args_check_key_store): Work with array of args_bool_key structs rather than linked list. Remove useless local variable "store". (args_key_extract_vl): Function removed. (args_key_extract): Takes array instead of va_list. * args.h (struct args_bool_key): Structure declared here. Loses the next pointer since not used for a linked list. (args_key_extract_vl): Function removed. (args_key_extract): Redeclared. * hash.c (hashv): Adapt to new args_key_extract function.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/hash.c b/hash.c
index f6a79370..1720aa10 100644
--- a/hash.c
+++ b/hash.c
@@ -1062,12 +1062,13 @@ void hash_process_weak(void)
val hashv(struct args *args)
{
val wkeys = nil, wvals = nil, equal = nil, userdata = nil;
- val hash = (args_keys_extract(args,
- weak_keys_k, nil, &wkeys,
- weak_vals_k, nil, &wvals,
- equal_based_k, nil, &equal,
- userdata_k, t, &userdata,
- nil),
+ struct args_bool_key akv[] = {
+ { weak_keys_k, nil, &wkeys },
+ { weak_vals_k, nil, &wvals },
+ { equal_based_k, nil, &equal },
+ { userdata_k, t, &userdata }
+ };
+ val hash = (args_keys_extract(args, akv, sizeof akv / sizeof akv[0]),
make_hash(wkeys, wvals, equal));
if (userdata)
set_hash_userdata(hash, userdata);