2009-02-27 17:57:06 +00:00
|
|
|
/*
|
|
|
|
* Unit test suite for debug functions.
|
|
|
|
*
|
|
|
|
* Copyright 2004 Patrik Stridvall
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnt.h"
|
|
|
|
|
|
|
|
#include "crtdbg.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
2009-12-22 11:50:11 +00:00
|
|
|
static void * (__cdecl *pMSVCRTD_operator_new_dbg)(size_t, int, const char *, int) = NULL;
|
2019-01-29 12:08:43 +00:00
|
|
|
static void * (__cdecl *pMSVCRTD_operator_delete)(void *) = NULL;
|
2009-02-27 17:57:06 +00:00
|
|
|
|
|
|
|
/* Some exports are only available in later versions */
|
|
|
|
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hModule,y)
|
2013-10-05 20:50:11 +00:00
|
|
|
#define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
|
2009-02-27 17:57:06 +00:00
|
|
|
|
2015-11-25 14:30:06 +00:00
|
|
|
static BOOL init_functions(void)
|
2009-02-27 17:57:06 +00:00
|
|
|
{
|
|
|
|
HMODULE hModule = LoadLibraryA("msvcrtd.dll");
|
|
|
|
|
|
|
|
if (!hModule) {
|
|
|
|
trace("LoadLibraryA failed to load msvcrtd.dll with GLE=%d\n", GetLastError());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-10-05 20:50:11 +00:00
|
|
|
if (sizeof(void *) > sizeof(int)) /* 64-bit has a different mangled name */
|
2019-01-29 12:08:43 +00:00
|
|
|
{
|
2013-10-05 20:50:11 +00:00
|
|
|
SET(pMSVCRTD_operator_new_dbg, "??2@YAPEAX_KHPEBDH@Z");
|
2019-01-29 12:08:43 +00:00
|
|
|
SET(pMSVCRTD_operator_delete, "??3@YAXPEAX@Z");
|
|
|
|
}
|
2013-10-05 20:50:11 +00:00
|
|
|
else
|
2019-01-29 12:08:43 +00:00
|
|
|
{
|
2013-10-05 20:50:11 +00:00
|
|
|
SET(pMSVCRTD_operator_new_dbg, "??2@YAPAXIHPBDH@Z");
|
2019-01-29 12:08:43 +00:00
|
|
|
SET(pMSVCRTD_operator_delete, "??3@YAXPAX@Z");
|
|
|
|
}
|
2013-10-05 20:50:11 +00:00
|
|
|
|
2009-02-27 17:57:06 +00:00
|
|
|
if (pMSVCRTD_operator_new_dbg == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
static void test_new(void)
|
|
|
|
{
|
|
|
|
void *mem;
|
|
|
|
|
|
|
|
mem = pMSVCRTD_operator_new_dbg(42, _NORMAL_BLOCK, __FILE__, __LINE__);
|
|
|
|
ok(mem != NULL, "memory not allocated\n");
|
2019-01-29 12:08:43 +00:00
|
|
|
pMSVCRTD_operator_delete(mem);
|
|
|
|
|
|
|
|
mem = pMSVCRTD_operator_new_dbg(42, _CRT_BLOCK, __FILE__, __LINE__);
|
|
|
|
ok(mem != NULL, "memory not allocated\n");
|
|
|
|
pMSVCRTD_operator_delete(mem);
|
2009-02-27 17:57:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
START_TEST(debug)
|
|
|
|
{
|
|
|
|
if (!init_functions())
|
|
|
|
return;
|
|
|
|
|
|
|
|
test_new();
|
|
|
|
}
|