Commit 6d799bfa authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Use heap structures and definitions from public header.

parent a2c6c313
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* handler and non atomic heap operations * handler and non atomic heap operations
*/ */
#include <malloc.h>
#include "msvcrt.h" #include "msvcrt.h"
#include "mtdll.h" #include "mtdll.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -246,9 +247,9 @@ int CDECL _heapchk(void) ...@@ -246,9 +247,9 @@ int CDECL _heapchk(void)
(sb_heap && !HeapValidate(sb_heap, 0, NULL))) (sb_heap && !HeapValidate(sb_heap, 0, NULL)))
{ {
msvcrt_set_errno(GetLastError()); msvcrt_set_errno(GetLastError());
return MSVCRT__HEAPBADNODE; return _HEAPBADNODE;
} }
return MSVCRT__HEAPOK; return _HEAPOK;
} }
/********************************************************************* /*********************************************************************
...@@ -269,7 +270,7 @@ int CDECL _heapmin(void) ...@@ -269,7 +270,7 @@ int CDECL _heapmin(void)
/********************************************************************* /*********************************************************************
* _heapwalk (MSVCRT.@) * _heapwalk (MSVCRT.@)
*/ */
int CDECL _heapwalk(struct MSVCRT__heapinfo* next) int CDECL _heapwalk(_HEAPINFO *next)
{ {
PROCESS_HEAP_ENTRY phe; PROCESS_HEAP_ENTRY phe;
...@@ -279,14 +280,14 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next) ...@@ -279,14 +280,14 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
LOCK_HEAP; LOCK_HEAP;
phe.lpData = next->_pentry; phe.lpData = next->_pentry;
phe.cbData = next->_size; 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 && if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
!HeapValidate( heap, 0, phe.lpData )) !HeapValidate( heap, 0, phe.lpData ))
{ {
UNLOCK_HEAP; UNLOCK_HEAP;
msvcrt_set_errno(GetLastError()); msvcrt_set_errno(GetLastError());
return MSVCRT__HEAPBADNODE; return _HEAPBADNODE;
} }
do do
...@@ -295,19 +296,19 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next) ...@@ -295,19 +296,19 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
{ {
UNLOCK_HEAP; UNLOCK_HEAP;
if (GetLastError() == ERROR_NO_MORE_ITEMS) if (GetLastError() == ERROR_NO_MORE_ITEMS)
return MSVCRT__HEAPEND; return _HEAPEND;
msvcrt_set_errno(GetLastError()); msvcrt_set_errno(GetLastError());
if (!phe.lpData) if (!phe.lpData)
return MSVCRT__HEAPBADBEGIN; return _HEAPBADBEGIN;
return MSVCRT__HEAPBADNODE; return _HEAPBADNODE;
} }
} while (phe.wFlags & (PROCESS_HEAP_REGION|PROCESS_HEAP_UNCOMMITTED_RANGE)); } while (phe.wFlags & (PROCESS_HEAP_REGION|PROCESS_HEAP_UNCOMMITTED_RANGE));
UNLOCK_HEAP; UNLOCK_HEAP;
next->_pentry = phe.lpData; next->_pentry = phe.lpData;
next->_size = phe.cbData; next->_size = phe.cbData;
next->_useflag = phe.wFlags & PROCESS_HEAP_ENTRY_BUSY ? MSVCRT__USEDENTRY : MSVCRT__FREEENTRY; next->_useflag = phe.wFlags & PROCESS_HEAP_ENTRY_BUSY ? _USEDENTRY : _FREEENTRY;
return MSVCRT__HEAPOK; return _HEAPOK;
} }
/********************************************************************* /*********************************************************************
...@@ -316,17 +317,17 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next) ...@@ -316,17 +317,17 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
int CDECL _heapset(unsigned int value) int CDECL _heapset(unsigned int value)
{ {
int retval; int retval;
struct MSVCRT__heapinfo heap; _HEAPINFO heap;
memset( &heap, 0, sizeof(heap) ); memset( &heap, 0, sizeof(heap) );
LOCK_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); memset(heap._pentry, value, heap._size);
} }
UNLOCK_HEAP; UNLOCK_HEAP;
return retval == MSVCRT__HEAPEND? MSVCRT__HEAPOK : retval; return retval == _HEAPEND ? _HEAPOK : retval;
} }
/********************************************************************* /*********************************************************************
......
...@@ -247,8 +247,6 @@ extern void msvcrt_free_scheduler_thread(void) DECLSPEC_HIDDEN; ...@@ -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 msvcrt_create_io_inherit_block(WORD*, BYTE**) DECLSPEC_HIDDEN;
extern unsigned int __cdecl _control87(unsigned int, unsigned int);
/* run-time error codes */ /* run-time error codes */
#define _RT_STACK 0 #define _RT_STACK 0
#define _RT_NULLPTR 1 #define _RT_NULLPTR 1
...@@ -287,12 +285,6 @@ extern FILE MSVCRT__iob[]; ...@@ -287,12 +285,6 @@ extern FILE MSVCRT__iob[];
typedef struct _complex _Dcomplex; typedef struct _complex _Dcomplex;
struct MSVCRT__heapinfo {
int* _pentry;
size_t _size;
int _useflag;
};
#ifdef __i386__ #ifdef __i386__
struct MSVCRT___JUMP_BUFFER { struct MSVCRT___JUMP_BUFFER {
unsigned long Ebp; unsigned long Ebp;
...@@ -560,16 +552,6 @@ struct MSVCRT__stat64 { ...@@ -560,16 +552,6 @@ struct MSVCRT__stat64 {
#define MSVCRT__P_NOWAITO 3 #define MSVCRT__P_NOWAITO 3
#define MSVCRT__P_DETACH 4 #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_DEFAULT 0
#define MSVCRT__OUT_TO_STDERR 1 #define MSVCRT__OUT_TO_STDERR 1
#define MSVCRT__OUT_TO_MSGBOX 2 #define MSVCRT__OUT_TO_MSGBOX 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment