M
Size: a a a
M
o
M
o
o
M
o
o
M
o
o
o
M
MG
std::fread(&fileData, 8, static_cast<size_t>(fileDataIndexEnd), fp);as after the call i get
fileData = {int8_t * | 0xdec183b0d8818f6} 0x0dec183b0d8818f6
error = read memory from 0xdec183b0d8818f6 failed (0 of 1 bytes read)
fileDataIndexEnd = {size_t} 1003487218810951855
AT
fileDataIndexEnd
bytes from file. does fileData have enought space for that ?AT
AT
AT
MG
std::FILE * fp = std::fopen(file_to_read, "rb");
if (fp != nullptr || fp != NULL) {
std::fseek(fp, 0, SEEK_END);
fileDataIndexEnd = static_cast<size_t>(std::ftell(fp));
fileDataIndexEnd--; // correct index, since size 1, as 1 byte, is at index 0
try {
fileData = new int8_t[fileDataIndexEnd];
} catch (...) {
fileData = nullptr;
return;
}
std::rewind(fp);
// read 8 bits, int8_t, for x amount of times : https://stackoverflow.com/a/6102180
std::fread(&fileData, 8, static_cast<size_t>(fileDataIndexEnd), fp);
std::fclose(fp);
succeeded = true;
}