diff options
author | Alexei Podtelezhnikov <apodtele@gmail.com> | 2021-09-07 17:06:27 -0400 |
---|---|---|
committer | Alexei Podtelezhnikov <apodtele@gmail.com> | 2021-09-07 17:06:27 -0400 |
commit | 7e26c7a6da8a2dffe16399d3d5548aa606b9b8c4 (patch) | |
tree | d3f8b76cde29ad2c95ffe279cdfdb0262ef6f80a | |
parent | 60a93ea2318f6626ae72933ef9a44e60da170325 (diff) | |
download | freetype2-7e26c7a6da8a2dffe16399d3d5548aa606b9b8c4.tar.gz |
[builds/windows] Use native memory allocation API.
* builds/windows/ftsystem.c (ft_alloc, ft_realloc, ft_free):
Wrap HeapAlloc, HeapReAlloc, and HeapFree.
(FT_New_Memory): Set the heap handle.
-rw-r--r-- | builds/windows/ftsystem.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/builds/windows/ftsystem.c b/builds/windows/ftsystem.c index 32c8edc06..9a6f0c4b0 100644 --- a/builds/windows/ftsystem.c +++ b/builds/windows/ftsystem.c @@ -25,11 +25,10 @@ #include <freetype/fttypes.h> #include <freetype/internal/ftstream.h> - /* memory-mapping includes and definitions */ + /* memory mapping and allocation includes and definitions */ +#define WIN32_LEAN_AND_MEAN #include <windows.h> -#include <stdlib.h> - /************************************************************************** * @@ -69,9 +68,7 @@ ft_alloc( FT_Memory memory, long size ) { - FT_UNUSED( memory ); - - return malloc( size ); + return HeapAlloc( memory->user, 0, size ); } @@ -105,10 +102,9 @@ long new_size, void* block ) { - FT_UNUSED( memory ); FT_UNUSED( cur_size ); - return realloc( block, new_size ); + return HeapReAlloc( memory->user, 0, block, new_size ); } @@ -131,9 +127,7 @@ ft_free( FT_Memory memory, void* block ) { - FT_UNUSED( memory ); - - free( block ); + HeapFree( memory->user, 0, block ); } @@ -357,13 +351,17 @@ FT_BASE_DEF( FT_Memory ) FT_New_Memory( void ) { + HANDLE heap; FT_Memory memory; - memory = (FT_Memory)malloc( sizeof ( *memory ) ); + heap = GetProcessHeap(); + memory = heap ? (FT_Memory)HeapAlloc( heap, 0, sizeof ( *memory ) ) + : NULL; + if ( memory ) { - memory->user = NULL; + memory->user = heap; memory->alloc = ft_alloc; memory->realloc = ft_realloc; memory->free = ft_free; |