2 * Wine heap memory allocation wrappers
4 * Copyright 2006 Jacek Caban for CodeWeavers
5 * Copyright 2013, 2018 Michael Stefaniuc
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #ifndef __WINE_WINE_HEAP_H
23 #define __WINE_WINE_HEAP_H
27 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(SIZE_T len
)
29 return HeapAlloc(GetProcessHeap(), 0, len
);
32 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(SIZE_T len
)
34 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
37 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem
, SIZE_T len
)
40 return HeapAlloc(GetProcessHeap(), 0, len
);
41 return HeapReAlloc(GetProcessHeap(), 0, mem
, len
);
44 static inline void heap_free(void *mem
)
46 HeapFree(GetProcessHeap(), 0, mem
);
49 static inline void *heap_calloc(SIZE_T count
, SIZE_T size
)
51 SIZE_T len
= count
* size
;
53 if (size
&& len
/ size
!= count
)
55 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
58 #endif /* __WINE_WINE_HEAP_H */