Code fixes. Correct the UWP fix

This commit is contained in:
Henrik Rydgård 2024-10-31 00:36:03 +01:00
parent 329b72f1ab
commit 184a3ecf2a
3 changed files with 11 additions and 4 deletions

View File

@ -1,11 +1,14 @@
#pragma once
#include <winapifamily.h>
// Utility file for using the MS CRT's memory tracking.
// crtdbg.h overloads malloc with malloc_dbg etc, but does not catch new. So here we go.
// To add a full check of memory overruns, throw in a _CrtCheckMemory(). Useful to narrow things down.
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#include <crtdbg.h>
#if defined(_DEBUG)

View File

@ -444,7 +444,7 @@ public:
void DrawIndexed(int vertexCount, int offset) override;
void DrawUP(const void *vdata, int vertexCount) override;
void DrawIndexedUP(const void *vdata, int vertexCount, const void *idata, int indexCount, IndexFormat ifmt) override;
void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, IndexFormat ifmt, Slice<ClippedDraw> draws);
void DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, const void *idata, int indexCount, IndexFormat ifmt, Slice<ClippedDraw> draws) override;
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;

View File

@ -1947,18 +1947,22 @@ struct ImGuiTableColumnSortSpecs
// Defining a custom placement new() with a custom parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
//-----------------------------------------------------------------------------
#ifdef _WIN32
#undef new
#endif
struct ImNewWrapper {};
inline void* operator new(size_t, ImNewWrapper, void* ptr) { return ptr; }
inline void operator delete(void*, ImNewWrapper, void*) {} // This is only required so we can use the symmetrical new()
#define IM_ALLOC(_SIZE) ImGui::MemAlloc(_SIZE)
#define IM_FREE(_PTR) ImGui::MemFree(_PTR)
#define IM_PLACEMENT_NEW(_PTR) new(ImNewWrapper(), _PTR)
#define IM_NEW(_TYPE) new(ImNewWrapper(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
#define IM_PLACEMENT_NEW(_PTR) new(ImNewWrapper{}, _PTR)
#define IM_NEW(_TYPE) new(ImNewWrapper{}, ImGui::MemAlloc(sizeof(_TYPE))) _TYPE
template<typename T> void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } }
#ifdef _WIN32
#include "Common/DbgNew.h"
#endif
//-----------------------------------------------------------------------------
// ImVector<>