mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:57:42 +00:00
LibCore+Userland+Tests: Convert Stream APIs to construct on heap
As per previous discussion, it was decided that the Stream classes should be constructed on the heap. While I don't personally agree with this change, it does have the benefit of avoiding Function object reconstructions due to the lambda passed to Notifier pointing to a stale object reference. This also has the benefit of not having to "box" objects for virtual usage, as the objects come pre-boxed. However, it means that we now hit the heap everytime we construct a TCPSocket for instance, which might not be desirable.
This commit is contained in:
parent
eb389db92c
commit
dbd25916a3
14 changed files with 163 additions and 162 deletions
|
@ -106,7 +106,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
server->on_ready_to_accept = [&next_id, &clients, &server, command] {
|
||||
int id = next_id++;
|
||||
|
||||
ErrorOr<Core::Stream::TCPSocket> maybe_client_socket = server->accept();
|
||||
auto maybe_client_socket = server->accept();
|
||||
if (maybe_client_socket.is_error()) {
|
||||
warnln("accept: {}", maybe_client_socket.error());
|
||||
return;
|
||||
|
@ -116,17 +116,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
int ptm_fd = posix_openpt(O_RDWR);
|
||||
if (ptm_fd < 0) {
|
||||
perror("posix_openpt");
|
||||
client_socket.close();
|
||||
client_socket->close();
|
||||
return;
|
||||
}
|
||||
if (grantpt(ptm_fd) < 0) {
|
||||
perror("grantpt");
|
||||
client_socket.close();
|
||||
client_socket->close();
|
||||
return;
|
||||
}
|
||||
if (unlockpt(ptm_fd) < 0) {
|
||||
perror("unlockpt");
|
||||
client_socket.close();
|
||||
client_socket->close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue