Skip to content

Commit

Permalink
Assert improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 12, 2023
1 parent 95c914a commit be65cf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Common/MemoryUtil.cpp
Expand Up @@ -26,6 +26,7 @@
#include "Common/MemoryUtil.h"
#include "Common/StringUtils.h"
#include "Common/SysError.h"
#include "Common/Data/Text/Parsers.h"

#ifdef _WIN32
#include "Common/CommonWindows.h"
Expand Down Expand Up @@ -257,8 +258,9 @@ void *AllocateAlignedMemory(size_t size, size_t alignment) {
}
#endif
#endif

_assert_msg_(ptr != nullptr, "Failed to allocate aligned memory of size %llu", (unsigned long long)size);
char temp[32];
NiceSizeFormat(size, temp, sizeof(temp));
_assert_msg_(ptr != nullptr, "Failed to allocate aligned memory of size %s (%llu)", temp, (unsigned long long)size);
return ptr;
}

Expand Down
1 change: 1 addition & 0 deletions GPU/Common/ReplacedTexture.cpp
Expand Up @@ -672,6 +672,7 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference
png.format = PNG_FORMAT_RGBA;

std::vector<uint8_t> &out = data_[mipLevel];
// TODO: Should probably try to handle out-of-memory gracefully here.
out.resize(level.w * level.h * 4);
if (!png_image_finish_read(&png, nullptr, &out[0], level.w * 4, nullptr)) {
ERROR_LOG(G3D, "Could not load texture replacement: %s - %s", filename.c_str(), png.message);
Expand Down

0 comments on commit be65cf0

Please sign in to comment.