From 71efb59873fd12f94a3fec0ab7369f9174db0d61 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Sat, 13 May 2017 22:04:03 +0200 Subject: [PATCH] terminal: add Cell_array destructor With the capability-quota mechanism, the terminal-session won't always be constructed completely on the first try (we may run out of caps in the middle of the construction). Therefore, all members of the object must be properly destructable. Furthermore, the patch replaces the sliced heap by a heap to avoid allocating a new dataspace for each line of the cell array. --- repos/gems/src/server/terminal/main.cc | 23 ++++++++++------------- repos/os/include/terminal/cell_array.h | 9 ++++++++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/repos/gems/src/server/terminal/main.cc b/repos/gems/src/server/terminal/main.cc index f81b9f494b..954c2ce6cf 100644 --- a/repos/gems/src/server/terminal/main.cc +++ b/repos/gems/src/server/terminal/main.cc @@ -284,9 +284,7 @@ namespace Terminal { Flush_callback_registry &_flush_callback_registry; Trigger_flush_callback &_trigger_flush_callback; - Genode::Attached_ram_dataspace _io_buffer; - Framebuffer::Mode _fb_mode; Genode::Dataspace_capability _fb_ds_cap; unsigned _char_width; @@ -489,15 +487,14 @@ namespace Terminal { */ Genode::size_t io_buffer_size = 4096; - Session_component *session = - new (md_alloc()) Session_component(_env, *md_alloc(), - _read_buffer, - _framebuffer, - io_buffer_size, - _flush_callback_registry, - _trigger_flush_callback, - _font_family); - return session; + return new (md_alloc()) + Session_component(_env, *md_alloc(), + _read_buffer, + _framebuffer, + io_buffer_size, + _flush_callback_registry, + _trigger_flush_callback, + _font_family); } public: @@ -532,7 +529,7 @@ struct Terminal::Main Input::Connection _input { _env }; Timer::Connection _timer { _env }; - Sliced_heap _sliced_heap { _env.ram(), _env.rm() }; + Heap _heap { _env.ram(), _env.rm() }; /* input read buffer */ Read_buffer _read_buffer; @@ -599,7 +596,7 @@ struct Terminal::Main unsigned char const *control) : _env(env), - _root(_env, _sliced_heap, + _root(_env, _heap, _read_buffer, _framebuffer, _flush_callback_registry, _trigger_flush_callback, diff --git a/repos/os/include/terminal/cell_array.h b/repos/os/include/terminal/cell_array.h index a1ff6b83e1..39fb57cfe0 100644 --- a/repos/os/include/terminal/cell_array.h +++ b/repos/os/include/terminal/cell_array.h @@ -89,7 +89,14 @@ class Cell_array _array[i] = new (alloc) CELL[num_cols]; } - /* XXX destructor is missing */ + ~Cell_array() + { + for (unsigned i = 0; i < _num_lines; i++) + Genode::destroy(_alloc, _array[i]); + + Genode::destroy(_alloc, _line_dirty); + Genode::destroy(_alloc, _array); + } void set_cell(int column, int line, CELL cell) {