Reactos
1/* The use of these four functions was creating unwanted imports
2 * from msvcrt.dll in kernel32.dll. */
3
4#define malloc libwine_malloc
5#define free libwine_free
6#define realloc libwine_realloc
7#define _strdup libwine__strdup
8
9#include "debug.c"
10
11__MINGW_ATTRIB_MALLOC
12void * __cdecl malloc(size_t size)
13{
14 return LocalAlloc(0, size);
15}
16
17void __cdecl free(void *ptr)
18{
19 LocalFree(ptr);
20}
21
22void * __cdecl realloc(void *ptr, size_t size)
23{
24 if (ptr == NULL) return malloc(size);
25 return LocalReAlloc(ptr, size, LMEM_MOVEABLE);
26}
27
28__MINGW_ATTRIB_MALLOC
29char * __cdecl _strdup(const char *str)
30{
31 char *newstr = malloc(strlen(str) + 1);
32 if (newstr) strcpy(newstr, str);
33 return newstr;
34}