params: removed tal context.

@rustyrussell showed we don't need temporary objects for params.

This means params no longer need a tal context.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
Mark Beckwith
2018-07-04 11:03:12 -05:00
committed by Rusty Russell
parent 32ccfa5b29
commit 1b50ea2abd
3 changed files with 22 additions and 25 deletions

View File

@@ -65,27 +65,27 @@ typedef bool(*param_cb)(const char *buffer, const jsmntok_t *tok, void *arg);
(cb), (arg), \
const char *, \
const jsmntok_t *), \
(arg), NULL, 0
(arg), 0
/*
* Same as above but for optional parameters.
*/
#define param_opt(ctx, name, cb, arg) \
#define param_opt(name, cb, arg) \
name"", \
typesafe_cb_preargs(bool, void *, \
(cb), *(arg), \
const char *, \
const jsmntok_t *), \
(arg), (ctx), sizeof(**arg)
(arg), sizeof(**arg)
/*
* For when you want an optional raw token.
*
* Note: weird sizeof() does type check that arg really is a (const) jsmntok_t **.
*/
#define param_opt_tok(ctx, name, arg) \
#define param_opt_tok(name, arg) \
name"", \
json_tok_tok, \
(arg) + 0*sizeof(*(arg) == (jsmntok_t *)NULL), \
(ctx), sizeof(const jsmntok_t *)
sizeof(const jsmntok_t *)
#endif /* LIGHTNING_LIGHTNINGD_PARAMS_H */