msvcrt: Use heap structures and definitions from public header.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-12-02 00:53:24 +01:00 committed by Alexandre Julliard
parent a2c6c31330
commit 6d799bfa06
2 changed files with 15 additions and 32 deletions

View File

@ -21,6 +21,7 @@
* handler and non atomic heap operations
*/
#include <malloc.h>
#include "msvcrt.h"
#include "mtdll.h"
#include "wine/debug.h"
@ -246,9 +247,9 @@ int CDECL _heapchk(void)
(sb_heap && !HeapValidate(sb_heap, 0, NULL)))
{
msvcrt_set_errno(GetLastError());
return MSVCRT__HEAPBADNODE;
return _HEAPBADNODE;
}
return MSVCRT__HEAPOK;
return _HEAPOK;
}
/*********************************************************************
@ -269,7 +270,7 @@ int CDECL _heapmin(void)
/*********************************************************************
* _heapwalk (MSVCRT.@)
*/
int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
int CDECL _heapwalk(_HEAPINFO *next)
{
PROCESS_HEAP_ENTRY phe;
@ -279,14 +280,14 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
LOCK_HEAP;
phe.lpData = next->_pentry;
phe.cbData = next->_size;
phe.wFlags = next->_useflag == MSVCRT__USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
!HeapValidate( heap, 0, phe.lpData ))
{
UNLOCK_HEAP;
msvcrt_set_errno(GetLastError());
return MSVCRT__HEAPBADNODE;
return _HEAPBADNODE;
}
do
@ -295,19 +296,19 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
{
UNLOCK_HEAP;
if (GetLastError() == ERROR_NO_MORE_ITEMS)
return MSVCRT__HEAPEND;
return _HEAPEND;
msvcrt_set_errno(GetLastError());
if (!phe.lpData)
return MSVCRT__HEAPBADBEGIN;
return MSVCRT__HEAPBADNODE;
return _HEAPBADBEGIN;
return _HEAPBADNODE;
}
} while (phe.wFlags & (PROCESS_HEAP_REGION|PROCESS_HEAP_UNCOMMITTED_RANGE));
UNLOCK_HEAP;
next->_pentry = phe.lpData;
next->_size = phe.cbData;
next->_useflag = phe.wFlags & PROCESS_HEAP_ENTRY_BUSY ? MSVCRT__USEDENTRY : MSVCRT__FREEENTRY;
return MSVCRT__HEAPOK;
next->_useflag = phe.wFlags & PROCESS_HEAP_ENTRY_BUSY ? _USEDENTRY : _FREEENTRY;
return _HEAPOK;
}
/*********************************************************************
@ -316,17 +317,17 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
int CDECL _heapset(unsigned int value)
{
int retval;
struct MSVCRT__heapinfo heap;
_HEAPINFO heap;
memset( &heap, 0, sizeof(heap) );
LOCK_HEAP;
while ((retval = _heapwalk(&heap)) == MSVCRT__HEAPOK)
while ((retval = _heapwalk(&heap)) == _HEAPOK)
{
if (heap._useflag == MSVCRT__FREEENTRY)
if (heap._useflag == _FREEENTRY)
memset(heap._pentry, value, heap._size);
}
UNLOCK_HEAP;
return retval == MSVCRT__HEAPEND? MSVCRT__HEAPOK : retval;
return retval == _HEAPEND ? _HEAPOK : retval;
}
/*********************************************************************

View File

@ -247,8 +247,6 @@ extern void msvcrt_free_scheduler_thread(void) DECLSPEC_HIDDEN;
extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**) DECLSPEC_HIDDEN;
extern unsigned int __cdecl _control87(unsigned int, unsigned int);
/* run-time error codes */
#define _RT_STACK 0
#define _RT_NULLPTR 1
@ -287,12 +285,6 @@ extern FILE MSVCRT__iob[];
typedef struct _complex _Dcomplex;
struct MSVCRT__heapinfo {
int* _pentry;
size_t _size;
int _useflag;
};
#ifdef __i386__
struct MSVCRT___JUMP_BUFFER {
unsigned long Ebp;
@ -560,16 +552,6 @@ struct MSVCRT__stat64 {
#define MSVCRT__P_NOWAITO 3
#define MSVCRT__P_DETACH 4
#define MSVCRT__HEAPEMPTY -1
#define MSVCRT__HEAPOK -2
#define MSVCRT__HEAPBADBEGIN -3
#define MSVCRT__HEAPBADNODE -4
#define MSVCRT__HEAPEND -5
#define MSVCRT__HEAPBADPTR -6
#define MSVCRT__FREEENTRY 0
#define MSVCRT__USEDENTRY 1
#define MSVCRT__OUT_TO_DEFAULT 0
#define MSVCRT__OUT_TO_STDERR 1
#define MSVCRT__OUT_TO_MSGBOX 2