- RtlReAllocateHeap shouldn't allocate memory if ptr == NULL.
[reactos.git] / reactos / lib / crtdll / stdlib / malloc.c
1 #include "precomp.h"
2 #include <msvcrt/stdlib.h>
3
4
5 /*
6 * @implemented
7 */
8 void* malloc(size_t _size)
9 {
10 return(HeapAlloc(GetProcessHeap(),0,_size));
11 }
12
13 /*
14 * @implemented
15 */
16 void free(void* _ptr)
17 {
18 HeapFree(GetProcessHeap(),0,_ptr);
19 }
20
21 /*
22 * @implemented
23 */
24 void* calloc(size_t _nmemb, size_t _size)
25 {
26 return(HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, _nmemb*_size));
27 }
28
29 /*
30 * @implemented
31 */
32 void* realloc(void* _ptr, size_t _size)
33 {
34 if (!_ptr)
35 return(HeapAlloc(GetProcessHeap(),0,_size));
36 return(HeapReAlloc(GetProcessHeap(),0,_ptr,_size));
37 }