Add msvcrt/malloc.h (for the MFC).
Add msvcrt/search.h.
Move duplicated definitions to the new headers.
Use malloc.h instead of stdlib.h when sensible.
diff --git a/include/msvcrt/malloc.h b/include/msvcrt/malloc.h
new file mode 100644
index 0000000..ec990ce
--- /dev/null
+++ b/include/msvcrt/malloc.h
@@ -0,0 +1,69 @@
+/*
+ * Heap definitions
+ *
+ * Copyright 2001 Francois Gouget.
+ */
+#ifndef __WINE_MALLOC_H
+#define __WINE_MALLOC_H
+
+#ifdef USE_MSVCRT_PREFIX
+#define MSVCRT(x) MSVCRT_##x
+#else
+#define MSVCRT(x) x
+#endif
+
+
+/* heap function constants */
+#define _HEAPEMPTY -1
+#define _HEAPOK -2
+#define _HEAPBADBEGIN -3
+#define _HEAPBADNODE -4
+#define _HEAPEND -5
+#define _HEAPBADPTR -6
+
+#define _FREEENTRY 0
+#define _USEDENTRY 1
+
+
+#ifndef MSVCRT_SIZE_T_DEFINED
+typedef unsigned int MSVCRT(size_t);
+#define MSVCRT_SIZE_T_DEFINED
+#endif
+
+typedef struct _heapinfo
+{
+ int* _pentry;
+ MSVCRT(size_t) _size;
+ int _useflag;
+} _HEAPINFO;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void* _alloca(MSVCRT(size_t));
+void* _expand(void*,MSVCRT(size_t));
+int _heapadd(void*,MSVCRT(size_t));
+int _heapchk(void);
+int _heapmin(void);
+int _heapset(unsigned int);
+MSVCRT(size_t) _heapused(MSVCRT(size_t)*,MSVCRT(size_t)*);
+int _heapwalk(_HEAPINFO*);
+MSVCRT(size_t) _msize(void*);
+
+void* MSVCRT(calloc)(MSVCRT(size_t),MSVCRT(size_t));
+void MSVCRT(free)(void*);
+void* MSVCRT(malloc)(MSVCRT(size_t));
+void* MSVCRT(realloc)(void*,MSVCRT(size_t));
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifndef USE_MSVCRT_PREFIX
+#define alloca _alloca
+#endif /* USE_MSVCRT_PREFIX */
+
+#endif /* __WINE_MALLOC_H */
diff --git a/include/msvcrt/search.h b/include/msvcrt/search.h
new file mode 100644
index 0000000..cd90ca6
--- /dev/null
+++ b/include/msvcrt/search.h
@@ -0,0 +1,44 @@
+/*
+ * Heap definitions
+ *
+ * Copyright 2001 Francois Gouget.
+ */
+#ifndef __WINE_SEARCH_H
+#define __WINE_SEARCH_H
+
+#ifdef USE_MSVCRT_PREFIX
+#define MSVCRT(x) MSVCRT_##x
+#else
+#define MSVCRT(x) x
+#endif
+
+
+#ifndef MSVCRT_SIZE_T_DEFINED
+typedef unsigned int MSVCRT(size_t);
+#define MSVCRT_SIZE_T_DEFINED
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int (*MSVCRT_compar_fn_t)(const void*,const void*);
+
+void* _lfind(const void*,const void*,unsigned int*,unsigned int,MSVCRT_compar_fn_t);
+void* _lsearch(const void*,void*,unsigned int*,unsigned int,MSVCRT_compar_fn_t);
+
+void* MSVCRT(bsearch)(const void*,const void*,MSVCRT(size_t),MSVCRT(size_t),MSVCRT_compar_fn_t);
+void MSVCRT(qsort)(void*,MSVCRT(size_t),MSVCRT(size_t),MSVCRT_compar_fn_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#ifndef USE_MSVCRT_PREFIX
+#define lfind _lfind
+#define lsearch _lsearch
+#endif /* USE_MSVCRT_PREFIX */
+
+#endif /* __WINE_SEARCH_H */
diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h
index 11736f9..1e28149 100644
--- a/include/msvcrt/stdlib.h
+++ b/include/msvcrt/stdlib.h
@@ -9,12 +9,8 @@
#define __WINE_STDLIB_H
#include "winnt.h"
-
-#ifdef USE_MSVCRT_PREFIX
-#define MSVCRT(x) MSVCRT_##x
-#else
-#define MSVCRT(x) x
-#endif
+#include "msvcrt/malloc.h" /* For size_t, malloc & co */
+#include "msvcrt/search.h" /* For bsearch and qsort */
#ifndef USE_MSVCRT_PREFIX
@@ -34,11 +30,6 @@
#endif
-#ifndef MSVCRT_SIZE_T_DEFINED
-typedef unsigned int MSVCRT(size_t);
-#define MSVCRT_SIZE_T_DEFINED
-#endif
-
typedef struct MSVCRT(_div_t) {
int quot;
int rem;
@@ -113,7 +104,6 @@
typedef int (*_onexit_t)(void);
-typedef int (*_pfunccmp_t)(const void*,const void*);
__int64 _atoi64(const char*);
@@ -151,8 +141,6 @@
double MSVCRT(atof)(const char*);
int MSVCRT(atoi)(const char*);
long MSVCRT(atol)(const char*);
-void* MSVCRT(bsearch)(const void*,const void*,MSVCRT(size_t),MSVCRT(size_t),_pfunccmp_t);
-void* MSVCRT(calloc)(MSVCRT(size_t),MSVCRT(size_t));
#ifdef __i386__
LONGLONG MSVCRT(div)(int,int);
ULONGLONG MSVCRT(ldiv)(long,long);
@@ -161,15 +149,11 @@
MSVCRT(ldiv_t) MSVCRT(ldiv)(long,long);
#endif
void MSVCRT(exit)(int);
-void MSVCRT(free)(void*);
char* MSVCRT(getenv)(const char*);
long MSVCRT(labs)(long);
-void* MSVCRT(malloc)(MSVCRT(size_t));
int MSVCRT(mblen)(const char*,MSVCRT(size_t));
void MSVCRT(perror)(const char*);
-void MSVCRT(qsort)(const void*,MSVCRT(size_t),MSVCRT(size_t),_pfunccmp_t);
int MSVCRT(rand)(void);
-void* MSVCRT(realloc)(void*,MSVCRT(size_t));
void MSVCRT(srand)(unsigned int);
double MSVCRT(strtod)(const char*,char**);
long MSVCRT(strtol)(const char*,char**,int);