diff options
Diffstat (limited to 'src/3rdparty/freetype/builds/unix/ftsystem.c')
-rw-r--r-- | src/3rdparty/freetype/builds/unix/ftsystem.c | 257 |
1 files changed, 137 insertions, 120 deletions
diff --git a/src/3rdparty/freetype/builds/unix/ftsystem.c b/src/3rdparty/freetype/builds/unix/ftsystem.c index 826713f948..a5a692de50 100644 --- a/src/3rdparty/freetype/builds/unix/ftsystem.c +++ b/src/3rdparty/freetype/builds/unix/ftsystem.c @@ -1,29 +1,30 @@ -/***************************************************************************/ -/* */ -/* ftsystem.c */ -/* */ -/* Unix-specific FreeType low-level system interface (body). */ -/* */ -/* Copyright (C) 1996-2019 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ +/**************************************************************************** + * + * ftsystem.c + * + * Unix-specific FreeType low-level system interface (body). + * + * Copyright (C) 1996-2023 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + */ #include <ft2build.h> /* we use our special ftconfig.h file, not the standard one */ #include <ftconfig.h> -#include FT_INTERNAL_DEBUG_H -#include FT_SYSTEM_H -#include FT_ERRORS_H -#include FT_TYPES_H -#include FT_INTERNAL_STREAM_H +//#include FT_CONFIG_CONFIG_H +#include <freetype/internal/ftdebug.h> +#include <freetype/ftsystem.h> +#include <freetype/fterrors.h> +#include <freetype/fttypes.h> +#include <freetype/internal/ftstream.h> /* memory-mapping includes and definitions */ #ifdef HAVE_UNISTD_H @@ -70,29 +71,40 @@ #include <errno.h> - /*************************************************************************/ - /* */ - /* MEMORY MANAGEMENT INTERFACE */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_alloc */ - /* */ - /* <Description> */ - /* The memory allocation function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* size :: The requested size in bytes. */ - /* */ - /* <Return> */ - /* The address of newly allocated block. */ - /* */ + /************************************************************************** + * + * MEMORY MANAGEMENT INTERFACE + * + */ + + + /************************************************************************** + * + * It is not necessary to do any error checking for the + * allocation-related functions. This will be done by the higher level + * routines like ft_mem_alloc() or ft_mem_realloc(). + * + */ + + + /************************************************************************** + * + * @Function: + * ft_alloc + * + * @Description: + * The memory allocation function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * size :: + * The requested size in bytes. + * + * @Return: + * The address of newly allocated block. + */ FT_CALLBACK_DEF( void* ) ft_alloc( FT_Memory memory, long size ) @@ -103,26 +115,30 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_realloc */ - /* */ - /* <Description> */ - /* The memory reallocation function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* cur_size :: The current size of the allocated memory block. */ - /* */ - /* new_size :: The newly requested size in bytes. */ - /* */ - /* block :: The current address of the block in memory. */ - /* */ - /* <Return> */ - /* The address of the reallocated memory block. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_realloc + * + * @Description: + * The memory reallocation function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * cur_size :: + * The current size of the allocated memory block. + * + * new_size :: + * The newly requested size in bytes. + * + * block :: + * The current address of the block in memory. + * + * @Return: + * The address of the reallocated memory block. + */ FT_CALLBACK_DEF( void* ) ft_realloc( FT_Memory memory, long cur_size, @@ -136,19 +152,21 @@ } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_free */ - /* */ - /* <Description> */ - /* The memory release function. */ - /* */ - /* <Input> */ - /* memory :: A pointer to the memory object. */ - /* */ - /* block :: The address of block in memory to be freed. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_free + * + * @Description: + * The memory release function. + * + * @Input: + * memory :: + * A pointer to the memory object. + * + * block :: + * The address of block in memory to be freed. + */ FT_CALLBACK_DEF( void ) ft_free( FT_Memory memory, void* block ) @@ -159,19 +177,19 @@ } - /*************************************************************************/ - /* */ - /* RESOURCE MANAGEMENT INTERFACE */ - /* */ - /*************************************************************************/ + /************************************************************************** + * + * RESOURCE MANAGEMENT INTERFACE + * + */ - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ + /************************************************************************** + * + * The macro FT_COMPONENT is used in trace mode. It is an implicit + * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log + * messages during execution. + */ #undef FT_COMPONENT #define FT_COMPONENT io @@ -180,17 +198,17 @@ #define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer ) - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_close_stream_by_munmap */ - /* */ - /* <Description> */ - /* The function to close a stream which is opened by mmap. */ - /* */ - /* <Input> */ - /* stream :: A pointer to the stream object. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_close_stream_by_munmap + * + * @Description: + * The function to close a stream which is opened by mmap. + * + * @Input: + * stream :: A pointer to the stream object. + */ FT_CALLBACK_DEF( void ) ft_close_stream_by_munmap( FT_Stream stream ) { @@ -198,29 +216,29 @@ stream->descriptor.pointer = NULL; stream->size = 0; - stream->base = 0; + stream->base = NULL; } - /*************************************************************************/ - /* */ - /* <Function> */ - /* ft_close_stream_by_free */ - /* */ - /* <Description> */ - /* The function to close a stream which is created by ft_alloc. */ - /* */ - /* <Input> */ - /* stream :: A pointer to the stream object. */ - /* */ + /************************************************************************** + * + * @Function: + * ft_close_stream_by_free + * + * @Description: + * The function to close a stream which is created by ft_alloc. + * + * @Input: + * stream :: A pointer to the stream object. + */ 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; - stream->base = 0; + stream->base = NULL; } @@ -296,8 +314,7 @@ file, 0 ); - /* on some RTOS, mmap might return 0 */ - if ( (long)stream->base != -1 && stream->base != NULL ) + if ( stream->base != MAP_FAILED ) stream->close = ft_close_stream_by_munmap; else { @@ -307,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 ) { @@ -348,16 +365,16 @@ stream->descriptor.pointer = stream->base; stream->pathname.pointer = (char*)filepathname; - stream->read = 0; + stream->read = NULL; FT_TRACE1(( "FT_Stream_Open:" )); - FT_TRACE1(( " opened `%s' (%d bytes) successfully\n", + FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n", filepathname, stream->size )); return FT_Err_Ok; Fail_Read: - ft_free( NULL, stream->base ); + ft_free( stream->memory, stream->base ); Fail_Map: close( file ); @@ -392,7 +409,7 @@ memory = (FT_Memory)malloc( sizeof ( *memory ) ); if ( memory ) { - memory->user = 0; + memory->user = NULL; memory->alloc = ft_alloc; memory->realloc = ft_realloc; memory->free = ft_free; |