diff options
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/monkey/dispatch.c | 13 | ||||
-rw-r--r-- | frontends/monkey/dispatch.h | 2 | ||||
-rw-r--r-- | frontends/monkey/main.c | 9 |
3 files changed, 23 insertions, 1 deletions
diff --git a/frontends/monkey/dispatch.c b/frontends/monkey/dispatch.c index e60325cf1..08bd352d5 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; @@ -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]; diff --git a/frontends/monkey/dispatch.h b/frontends/monkey/dispatch.h index dc6e50a0b..11b1c0239 100644 --- a/frontends/monkey/dispatch.h +++ b/frontends/monkey/dispatch.h @@ -25,4 +25,6 @@ nserror monkey_register_handler(const char *cmd, handle_command_fn fn); void monkey_process_command(void); +void monkey_free_handlers(void); + #endif /* NETSURF_MONKEY_DISPATCH_H */ diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c index 1e496cb0f..0b7efda29 100644 --- a/frontends/monkey/main.c +++ b/frontends/monkey/main.c @@ -380,6 +380,12 @@ main(int argc, char **argv) urldb_load(nsoption_charp(url_file)); urldb_load_cookies(nsoption_charp(cookie_file)); + /* Free resource paths now we're done finding resources */ + for (char **s = respaths; *s != NULL; s++) { + free(*s); + } + free(respaths); + ret = monkey_register_handler("QUIT", quit_handler); if (ret != NSERROR_OK) { die("quit handler failed to register"); @@ -421,5 +427,8 @@ main(int argc, char **argv) /* finalise logging */ nslog_finalise(); + /* And free any monkey-specific bits */ + monkey_free_handlers(); + return 0; } |