diff --git a/builds/unix/ftsystem.c b/builds/unix/ftsystem.c index 19ef3a28e..7fc9941d8 100644 --- a/builds/unix/ftsystem.c +++ b/builds/unix/ftsystem.c @@ -233,7 +233,7 @@ FT_CALLBACK_DEF( void ) ft_close_stream_by_free( FT_Stream stream ) { - ft_free( NULL, stream->descriptor.pointer ); + ft_free( stream->memory, stream->descriptor.pointer ); stream->descriptor.pointer = NULL; stream->size = 0; @@ -324,7 +324,7 @@ FT_ERROR(( "FT_Stream_Open:" )); FT_ERROR(( " could not `mmap' file `%s'\n", filepathname )); - stream->base = (unsigned char*)ft_alloc( NULL, stream->size ); + stream->base = (unsigned char*)ft_alloc( stream->memory, stream->size ); if ( !stream->base ) { @@ -374,7 +374,7 @@ return FT_Err_Ok; Fail_Read: - ft_free( NULL, stream->base ); + ft_free( stream->memory, stream->base ); Fail_Map: close( file ); diff --git a/builds/windows/ftsystem.c b/builds/windows/ftsystem.c index bab7b31d3..1ebadd49f 100644 --- a/builds/windows/ftsystem.c +++ b/builds/windows/ftsystem.c @@ -188,7 +188,7 @@ FT_CALLBACK_DEF( void ) ft_close_stream_by_free( FT_Stream stream ) { - ft_free( NULL, stream->descriptor.pointer ); + ft_free( stream->memory, stream->descriptor.pointer ); stream->descriptor.pointer = NULL; stream->size = 0; @@ -323,7 +323,7 @@ FT_ERROR(( "FT_Stream_Open:" )); FT_ERROR(( " could not `mmap' file `%s'\n", filepathname )); - stream->base = (unsigned char*)ft_alloc( NULL, stream->size ); + stream->base = (unsigned char*)ft_alloc( stream->memory, stream->size ); if ( !stream->base ) { @@ -369,7 +369,7 @@ return FT_Err_Ok; Fail_Read: - ft_free( NULL, stream->base ); + ft_free( stream->memory, stream->base ); Fail_Open: CloseHandle( file ); diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 2c929dbc1..19f794e12 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -221,6 +221,7 @@ FT_Stream_OpenMemory( stream, (const FT_Byte*)args->memory_base, (FT_ULong)args->memory_size ); + stream->memory = memory; } #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT @@ -231,6 +232,7 @@ if ( FT_NEW( stream ) ) goto Exit; + stream->memory = memory; error = FT_Stream_Open( stream, args->pathname ); if ( error ) FT_FREE( stream ); @@ -241,8 +243,9 @@ /* in this case, we do not need to allocate a new stream object */ /* since the caller is responsible for closing it himself */ - stream = args->stream; - error = FT_Err_Ok; + stream = args->stream; + stream->memory = memory; + error = FT_Err_Ok; } #endif @@ -255,10 +258,7 @@ } if ( !error ) - { - stream->memory = memory; *astream = stream; - } Exit: return error;