xref: /reactos/sdk/lib/3rdparty/libwine/debug_ros.c (revision 50cf16b3)
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
12 void * __cdecl malloc(size_t size)
13 {
14     return LocalAlloc(0, size);
15 }
16 
17 void __cdecl free(void *ptr)
18 {
19     LocalFree(ptr);
20 }
21 
22 void * __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
29 char * __cdecl _strdup(const char *str)
30 {
31     char *newstr = malloc(strlen(str) + 1);
32     if (newstr) strcpy(newstr, str);
33     return newstr;
34 }
35