From c0ec37dcbc7778cfaf34b57e332be36110d6d705 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 18 Oct 2021 10:08:07 +0200 Subject: [PATCH] tty: fix construction/destruction There is no need to construct and destruct nested objects. The new and delete calls on the struct will take care of it. However, some fields have C functions for construction/destruction and these should be called. Change-Id: I09d5930f499ef3fa4ff580d482c682172b00b6a3 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4603 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- src/add-ons/kernel/generic/tty/tty.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/add-ons/kernel/generic/tty/tty.cpp b/src/add-ons/kernel/generic/tty/tty.cpp index a5594d1b1b..8daf2f1d47 100644 --- a/src/add-ons/kernel/generic/tty/tty.cpp +++ b/src/add-ons/kernel/generic/tty/tty.cpp @@ -1291,11 +1291,6 @@ tty_create(tty_service_func func, bool isMaster) tty->service_func = func; - // construct the queues - new(&tty->reader_queue) RequestQueue; - new(&tty->writer_queue) RequestQueue; - new(&tty->cookies) TTYCookieList; - return tty; } @@ -1303,12 +1298,10 @@ tty_create(tty_service_func func, bool isMaster) void tty_destroy(struct tty* tty) { - // destroy the queues - tty->reader_queue.~RequestQueue(); - tty->writer_queue.~RequestQueue(); - tty->cookies.~TTYCookieList(); - + TRACE(("tty_destroy(%p)\n", tty)); uninit_line_buffer(tty->input_buffer); + delete_select_sync_pool(tty->select_pool); + mutex_destroy(&tty->lock); delete tty; } @@ -1435,13 +1428,11 @@ tty_close_cookie(tty_cookie* cookie) } requestLocker.Unlock(); + + // notify a select write event on the other tty, if we've closed this tty + if (cookie->other_tty->open_count > 0) + tty_notify_select_event(cookie->other_tty, B_SELECT_WRITE); } - - // notify pending select()s and cleanup the select sync pool - - // notify a select write event on the other tty, if we've closed this tty - if (cookie->tty->open_count == 0 && cookie->other_tty->open_count > 0) - tty_notify_select_event(cookie->other_tty, B_SELECT_WRITE); }