From 4a8722ce9fcbb66abe2bd304e5a4bad03d842821 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 4 Dec 2017 06:31:19 -0800 Subject: 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. --- args.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'args.h') diff --git a/args.h b/args.h index 6e0036c0..b3bb91db 100644 --- a/args.h +++ b/args.h @@ -41,6 +41,12 @@ typedef int arg_index; (coerce(struct args *, \ alloca(offsetof(struct args, arg) + (N)*sizeof (val)))) +struct args_bool_key { + val key; + val arg_p; + val *store; +}; + INLINE struct args *args_init_list(struct args *args, cnum argc, val list) { args->argc = argc; @@ -189,5 +195,4 @@ val args_copy_to_list(struct args *args); void args_for_each(struct args *args, int (*fn)(val arg, int ix, mem_t *ctx), mem_t *ctx); -void args_keys_extract_vl(struct args *args, va_list); -void args_keys_extract(struct args *args, ...); +void args_keys_extract(struct args *args, struct args_bool_key *, int n); -- cgit v1.2.3