diff options
author | Jesse Luehrs <doy@tozt.net> | 2016-05-10 17:25:12 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2016-05-10 17:31:39 -0400 |
commit | ec77a7037586864ece6505c448ab5c15bf8a57d9 (patch) | |
tree | ad23ca8d2ded6ffc0a9d9c6c5320e457c37ece32 /src/loop.c | |
parent | 9118ead5ae15548c8a5b96340f9a0a24b3104e32 (diff) | |
download | runes-ec77a7037586864ece6505c448ab5c15bf8a57d9.tar.gz runes-ec77a7037586864ece6505c448ab5c15bf8a57d9.zip |
refactor how submodules are handled
let them own their own memory, so that they can free themselves once
they exit the loop. also split out the parts of the terminal that we
only want to initialize once, even if we open multiple terminal windows
Diffstat (limited to 'src/loop.c')
-rw-r--r-- | src/loop.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -21,9 +21,14 @@ static void runes_loop_do_after_work(uv_work_t *req, int status); static void runes_loop_timer_cb(uv_timer_t *handle); static void runes_loop_free_handle(uv_handle_t *handle); -void runes_loop_init(RunesLoop *loop) +RunesLoop *runes_loop_new() { + RunesLoop *loop; + + loop = calloc(1, sizeof(RunesLoop)); loop->loop = uv_default_loop(); + + return loop; } void runes_loop_run(RunesLoop *loop) @@ -63,9 +68,11 @@ void runes_loop_timer_set(RunesLoop *loop, int timeout, int repeat, uv_timer_start(timer_req, runes_loop_timer_cb, timeout, repeat); } -void runes_loop_cleanup(RunesLoop *loop) +void runes_loop_delete(RunesLoop *loop) { uv_loop_close(loop->loop); + + free(loop); } static void runes_loop_do_work(uv_work_t *req) |