1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-12-28 00:17:13 +00:00

Fix up controller cleanup order

This commit is contained in:
cathery 2020-04-17 12:05:02 +03:00
parent 979f847b25
commit a00188868c
2 changed files with 7 additions and 7 deletions

View File

@ -13,7 +13,6 @@ SwitchControllerHandler::SwitchControllerHandler(std::unique_ptr<IController> &&
SwitchControllerHandler::~SwitchControllerHandler()
{
Exit();
}
Result SwitchControllerHandler::Initialize()

View File

@ -11,6 +11,11 @@ SwitchUSBEndpoint::SwitchUSBEndpoint(UsbHsClientIfSession &if_session, usb_endpo
SwitchUSBEndpoint::~SwitchUSBEndpoint()
{
Close();
if (m_buffer != nullptr)
{
free(m_buffer);
m_buffer = nullptr;
}
}
Result SwitchUSBEndpoint::Open(int maxPacketSize)
@ -21,6 +26,8 @@ Result SwitchUSBEndpoint::Open(int maxPacketSize)
if (R_FAILED(rc))
return 73011;
if (m_buffer != nullptr)
free(m_buffer);
m_buffer = memalign(0x1000, maxPacketSize);
if (m_buffer == nullptr)
return -1;
@ -29,12 +36,6 @@ Result SwitchUSBEndpoint::Open(int maxPacketSize)
void SwitchUSBEndpoint::Close()
{
if (m_buffer != nullptr)
{
free(m_buffer);
m_buffer = nullptr;
}
usbHsEpClose(&m_epSession);
}