Module: wine Branch: master Commit: d5a897f46f6bb4acc23033571c5135f4d1835344 URL: https://source.winehq.org/git/wine.git/?a=commit;h=d5a897f46f6bb4acc23033571...
Author: Michael Stefaniuc mstefani@winehq.org Date: Fri Jan 26 20:56:14 2018 +0100
include: Add generic HeapAlloc() wrappers.
Signed-off-by: Michael Stefaniuc mstefani@winehq.org Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
include/wine/heap.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/include/wine/heap.h b/include/wine/heap.h new file mode 100644 index 0000000..014ef61 --- /dev/null +++ b/include/wine/heap.h @@ -0,0 +1,49 @@ +/* + * Wine heap memory allocation wrappers + * + * Copyright 2006 Jacek Caban for CodeWeavers + * Copyright 2013, 2018 Michael Stefaniuc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_WINE_HEAP_H +#define __WINE_WINE_HEAP_H + +#include <windef.h> + +static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(SIZE_T len) +{ + return HeapAlloc(GetProcessHeap(), 0, len); +} + +static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(SIZE_T len) +{ + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); +} + +static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, SIZE_T len) +{ + if (!mem) + return HeapAlloc(GetProcessHeap(), 0, len); + return HeapReAlloc(GetProcessHeap(), 0, mem, len); +} + +static inline void heap_free(void *mem) +{ + HeapFree(GetProcessHeap(), 0, mem); +} + +#endif /* __WINE_WINE_HEAP_H */