Skip to content

Commit a2213cc

Browse files
Fix the debugging 'new' defines for Windows
They didn't supply the correct overloads, breaking most uses of 'new' when compiling in debug mode.
1 parent 132a534 commit a2213cc

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

engine/src/sysdefs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ typedef struct __MCWinSysEnhMetafileHandle *MCWinSysEnhMetafileHandle;
279279

280280
#define _DEBUG_MEMORY
281281

282-
inline void *operator new(size_t size, const char *fnm, int line) {return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);}
283-
inline void *operator new[](size_t size, const char *fnm, int line) {return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);}
282+
inline void *operator new(size_t size, std::nothrow_t, const char *fnm, int line) throw () {return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);}
283+
inline void *operator new[](size_t size, std::nothrow_t, const char *fnm, int line) throw () {return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);}
284284

285-
inline void *operator new(size_t, void *p, const char *, int)
285+
inline void *operator new(size_t, void *p, const char *, long)
286286
{
287287
return p;
288288
}

revdb/src/dbdriver.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3131
#define _CRTDBG_MAP_ALLOC
3232
#include <crtdbg.h>
3333

34-
inline void *operator new(size_t size, const char *fnm, int line)
35-
{
36-
return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);
37-
}
34+
#define _DEBUG_MEMORY
35+
#undef new
36+
#undef delete
3837

39-
inline void *operator new[](size_t size, const char *fnm, int line)
38+
inline void *operator new(size_t size, std::nothrow_t, const char *fnm, int line) throw () {return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);}
39+
inline void *operator new[](size_t size, std::nothrow_t, const char *fnm, int line) throw () {return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);}
40+
41+
inline void *operator new(size_t, void *p, const char *, long)
4042
{
41-
return _malloc_dbg(size, _NORMAL_BLOCK, fnm, line);
43+
return p;
4244
}
4345

44-
#define new new(__FILE__, __LINE__)
45-
46+
#define new(...) new(__VA_ARGS__, __FILE__, __LINE__ )
47+
#define delete delete
4648
#endif
4749

4850

0 commit comments

Comments
 (0)