Skip to content

Commit c07ab1b

Browse files
committed
Minor tweaks to "Memory override" pull request
1 parent 22a9555 commit c07ab1b

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

Diff for: imconfig.h

+3-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55
#pragma once
66

77
//---- Define your own malloc/free/realloc functions if you want to override internal memory allocations for ImGui
8-
/*
9-
#define IM_MALLOC(_SIZE) MyMalloc(_SIZE)
10-
#define IM_FREE(_PTR) MyFree(_PTR)
11-
#define IM_REALLOC(_PTR, _SIZE) MyRealloc(_PTR, _SIZE)
12-
13-
#include <stdlib.h> // size_t
14-
void* MyMalloc(size_t size);
15-
void MyFree(void *ptr);
16-
void* MyRealloc(void *ptr, size_t size);
17-
*/
8+
//#define IM_MALLOC(_SIZE) MyMalloc(_SIZE) // void* MyMalloc(size_t size);
9+
//#define IM_FREE(_PTR) MyFree(_PTR) // void MyFree(void *ptr);
10+
//#define IM_REALLOC(_PTR, _SIZE) MyRealloc(_PTR, _SIZE) // void* MyRealloc(void *ptr, size_t size);
1811

1912
//---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
2013
//#include <vector>

Diff for: imgui.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@
194194
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
195195
#endif
196196

197-
198197
//-------------------------------------------------------------------------
199198
// Forward Declarations
200199
//-------------------------------------------------------------------------
@@ -666,7 +665,7 @@ struct ImGuiState
666665
// Logging
667666
bool LogEnabled;
668667
FILE* LogFile;
669-
ImGuiTextBuffer* LogClipboard;
668+
ImGuiTextBuffer* LogClipboard; // pointer so our GImGui static constructor doesn't call heap allocators.
670669
int LogAutoExpandMaxDepth;
671670

672671
ImGuiState()

Diff for: imgui.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct ImGuiWindow;
1717
#include "imconfig.h"
1818
#include <float.h> // FLT_MAX
1919
#include <stdarg.h> // va_list
20-
#include <stdlib.h> // NULL
20+
#include <stdlib.h> // NULL, malloc
2121

2222
#ifndef IM_MALLOC
2323
#define IM_MALLOC(_SIZE) malloc((_SIZE))
@@ -70,7 +70,6 @@ struct ImVec4
7070
// std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
7171
// this implementation does NOT call c++ constructors! we don't need them! also only provide the minimum functionalities we need.
7272
#ifndef ImVector
73-
7473
template<typename T>
7574
class ImVector
7675
{

0 commit comments

Comments
 (0)