diff options
Diffstat (limited to 'frontends/monkey/dispatch.c')
-rw-r--r-- | frontends/monkey/dispatch.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/frontends/monkey/dispatch.c b/frontends/monkey/dispatch.c index e60325cf1..09d7e7331 100644 --- a/frontends/monkey/dispatch.c +++ b/frontends/monkey/dispatch.c @@ -29,7 +29,7 @@ typedef struct cmdhandler { struct cmdhandler *r_next, *r_prev; - const char *cmd; + char *cmd; handle_command_fn fn; } monkey_cmdhandler_t; @@ -38,7 +38,7 @@ static monkey_cmdhandler_t *handler_ring = NULL; nserror monkey_register_handler(const char *cmd, handle_command_fn fn) { - monkey_cmdhandler_t *ret = calloc(sizeof(*ret), 1); + monkey_cmdhandler_t *ret = calloc(1, sizeof(*ret)); if (ret == NULL) { NSLOG(netsurf, INFO, "Unable to allocate handler"); return NSERROR_NOMEM; @@ -50,6 +50,17 @@ monkey_register_handler(const char *cmd, handle_command_fn fn) } void +monkey_free_handlers(void) +{ + while (handler_ring != NULL) { + monkey_cmdhandler_t *handler = handler_ring; + RING_REMOVE(handler_ring, handler); + free(handler->cmd); + free(handler); + } +} + +void monkey_process_command(void) { char buffer[PATH_MAX]; |