1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +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:
sin-ack 2021-12-29 22:31:45 +00:00 committed by Ali Mohammad Pur
parent eb389db92c
commit dbd25916a3
14 changed files with 163 additions and 162 deletions

View file

@ -69,7 +69,7 @@ ErrorOr<void> TCPServer::set_blocking(bool blocking)
return {};
}
ErrorOr<Stream::TCPSocket> TCPServer::accept()
ErrorOr<NonnullOwnPtr<Stream::TCPSocket>> TCPServer::accept()
{
VERIFY(m_listening);
sockaddr_in in;
@ -86,8 +86,8 @@ ErrorOr<Stream::TCPSocket> TCPServer::accept()
// FIXME: Ideally, we should let the caller decide whether it wants the
// socket to be nonblocking or not, but there are currently places
// which depend on this.
TRY(socket.set_blocking(false));
TRY(socket.set_close_on_exec(true));
TRY(socket->set_blocking(false));
TRY(socket->set_close_on_exec(true));
#endif
return socket;