Browse Source

libplugin: use a typesafe_cb for plugin_timer

travis-debug
darosior 5 years ago
committed by Rusty Russell
parent
commit
e7b0c24db2
  1. 6
      plugins/libplugin.c
  2. 14
      plugins/libplugin.h

6
plugins/libplugin.c

@ -835,9 +835,9 @@ static void destroy_plugin_timer(struct plugin_timer *timer, struct plugin *p)
timer_del(&p->timers, &timer->timer);
}
struct plugin_timer *plugin_timer(struct plugin *p, struct timerel t,
void (*cb)(void *cb_arg),
void *cb_arg)
struct plugin_timer *plugin_timer_(struct plugin *p, struct timerel t,
void (*cb)(void *cb_arg),
void *cb_arg)
{
struct plugin_timer *timer = tal(NULL, struct plugin_timer);
timer->cb = cb;

14
plugins/libplugin.h

@ -210,10 +210,16 @@ struct command_result *timer_complete(struct plugin *p);
* Freeing this releases the timer, otherwise it's freed after @cb
* if it hasn't been freed already.
*/
struct plugin_timer *plugin_timer(struct plugin *p,
struct timerel t,
void (*cb)(void *cb_arg),
void *cb_arg);
struct plugin_timer *plugin_timer_(struct plugin *p,
struct timerel t,
void (*cb)(void *cb_arg),
void *cb_arg);
#define plugin_timer(plugin, time, cb, cb_arg) \
plugin_timer_((plugin), (time), \
typesafe_cb(void, void *, \
(cb), (cb_arg)), \
(cb_arg)) \
/* Log something */
void plugin_log(struct plugin *p, enum log_level l, const char *fmt, ...) PRINTF_FMT(3, 4);

Loading…
Cancel
Save