Clear buffers after we're done with them in BufferData()

This commit is contained in:
Huntereb 2019-12-09 19:46:02 -05:00
parent 96257eb43a
commit c9e020da74
2 changed files with 12 additions and 10 deletions

View File

@ -8,8 +8,8 @@
#include "data/byte_buffer.hpp"
#include "data/buffered_placeholder_writer.hpp"
#include "util/usb_util.hpp"
#include "error.hpp"
#include "debug.h"
#include "util/error.hpp"
#include "util/debug.h"
#include "sdInstall.hpp"
#include "util/util.hpp"
#include "util/usb_comms_awoo.h"
@ -156,8 +156,9 @@ namespace tin::install::nsp
{
LOG_DEBUG("buffering 0x%lx-0x%lx", offset, offset + size);
tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(m_nspName, offset, size);
u8* ourBuffer = (u8*)memalign(0x1000, header.dataSize);
if (tin::util::USBRead(ourBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed");
memcpy(buf, ourBuffer, header.dataSize);
u8* tempBuffer = (u8*)memalign(0x1000, header.dataSize);
if (tin::util::USBRead(tempBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed");
memcpy(buf, tempBuffer, header.dataSize);
free(tempBuffer);
}
}

View File

@ -8,8 +8,8 @@
#include "data/byte_buffer.hpp"
#include "data/buffered_placeholder_writer.hpp"
#include "util/usb_util.hpp"
#include "error.hpp"
#include "debug.h"
#include "util/error.hpp"
#include "util/debug.h"
#include "sdInstall.hpp"
#include "util/util.hpp"
#include "util/usb_comms_awoo.h"
@ -156,8 +156,9 @@ namespace tin::install::xci
{
LOG_DEBUG("buffering 0x%lx-0x%lx", offset, offset + size);
tin::util::USBCmdHeader header = tin::util::USBCmdManager::SendFileRangeCmd(m_xciName, offset, size);
u8* ourBuffer = (u8*)memalign(0x1000, header.dataSize);
if (tin::util::USBRead(ourBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed");
memcpy(buf, ourBuffer, header.dataSize);
u8* tempBuffer = (u8*)memalign(0x1000, header.dataSize);
if (tin::util::USBRead(tempBuffer, header.dataSize) == 0) THROW_FORMAT("USB transfer timed out or failed");
memcpy(buf, tempBuffer, header.dataSize);
free(tempBuffer);
}
}