src/java.desktop/share/native/libfreetype/src/base/ftutil.c
changeset 54876 da3834261f0c
parent 49234 3375a8039fde
equal deleted inserted replaced
54875:bcfedddcf4ce 54876:da3834261f0c
     1 /***************************************************************************/
     1 /****************************************************************************
     2 /*                                                                         */
     2  *
     3 /*  ftutil.c                                                               */
     3  * ftutil.c
     4 /*                                                                         */
     4  *
     5 /*    FreeType utility file for memory and list management (body).         */
     5  *   FreeType utility file for memory and list management (body).
     6 /*                                                                         */
     6  *
     7 /*  Copyright 2002-2018 by                                                 */
     7  * Copyright (C) 2002-2019 by
     8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
     8  * David Turner, Robert Wilhelm, and Werner Lemberg.
     9 /*                                                                         */
     9  *
    10 /*  This file is part of the FreeType project, and may only be used,       */
    10  * This file is part of the FreeType project, and may only be used,
    11 /*  modified, and distributed under the terms of the FreeType project      */
    11  * modified, and distributed under the terms of the FreeType project
    12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    12  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    13 /*  this file you indicate that you have read the license and              */
    13  * this file you indicate that you have read the license and
    14 /*  understand and accept it fully.                                        */
    14  * understand and accept it fully.
    15 /*                                                                         */
    15  *
    16 /***************************************************************************/
    16  */
    17 
    17 
    18 
    18 
    19 #include <ft2build.h>
    19 #include <ft2build.h>
    20 #include FT_INTERNAL_DEBUG_H
    20 #include FT_INTERNAL_DEBUG_H
    21 #include FT_INTERNAL_MEMORY_H
    21 #include FT_INTERNAL_MEMORY_H
    22 #include FT_INTERNAL_OBJECTS_H
    22 #include FT_INTERNAL_OBJECTS_H
    23 #include FT_LIST_H
    23 #include FT_LIST_H
    24 
    24 
    25 
    25 
    26   /*************************************************************************/
    26   /**************************************************************************
    27   /*                                                                       */
    27    *
    28   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
    28    * The macro FT_COMPONENT is used in trace mode.  It is an implicit
    29   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
    29    * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
    30   /* messages during execution.                                            */
    30    * messages during execution.
    31   /*                                                                       */
    31    */
    32 #undef  FT_COMPONENT
    32 #undef  FT_COMPONENT
    33 #define FT_COMPONENT  trace_memory
    33 #define FT_COMPONENT  memory
    34 
    34 
    35 
    35 
    36   /*************************************************************************/
    36   /*************************************************************************/
    37   /*************************************************************************/
    37   /*************************************************************************/
    38   /*************************************************************************/
    38   /*************************************************************************/
    52                 FT_Error  *p_error )
    52                 FT_Error  *p_error )
    53   {
    53   {
    54     FT_Error    error;
    54     FT_Error    error;
    55     FT_Pointer  block = ft_mem_qalloc( memory, size, &error );
    55     FT_Pointer  block = ft_mem_qalloc( memory, size, &error );
    56 
    56 
    57     if ( !error && size > 0 )
    57     if ( !error && block && size > 0 )
    58       FT_MEM_ZERO( block, size );
    58       FT_MEM_ZERO( block, size );
    59 
    59 
    60     *p_error = error;
    60     *p_error = error;
    61     return block;
    61     return block;
    62   }
    62   }
    99     FT_Error  error = FT_Err_Ok;
    99     FT_Error  error = FT_Err_Ok;
   100 
   100 
   101 
   101 
   102     block = ft_mem_qrealloc( memory, item_size,
   102     block = ft_mem_qrealloc( memory, item_size,
   103                              cur_count, new_count, block, &error );
   103                              cur_count, new_count, block, &error );
   104     if ( !error && new_count > cur_count )
   104     if ( !error && block && new_count > cur_count )
   105       FT_MEM_ZERO( (char*)block + cur_count * item_size,
   105       FT_MEM_ZERO( (char*)block + cur_count * item_size,
   106                    ( new_count - cur_count ) * item_size );
   106                    ( new_count - cur_count ) * item_size );
   107 
   107 
   108     *p_error = error;
   108     *p_error = error;
   109     return block;
   109     return block;
   183   {
   183   {
   184     FT_Error    error;
   184     FT_Error    error;
   185     FT_Pointer  p = ft_mem_qalloc( memory, (FT_Long)size, &error );
   185     FT_Pointer  p = ft_mem_qalloc( memory, (FT_Long)size, &error );
   186 
   186 
   187 
   187 
   188     if ( !error && address )
   188     if ( !error && address && size > 0 )
   189       ft_memcpy( p, address, size );
   189       ft_memcpy( p, address, size );
   190 
   190 
   191     *p_error = error;
   191     *p_error = error;
   192     return p;
   192     return p;
   193   }
   193   }
   234   /*************************************************************************/
   234   /*************************************************************************/
   235   /*************************************************************************/
   235   /*************************************************************************/
   236   /*************************************************************************/
   236   /*************************************************************************/
   237 
   237 
   238 #undef  FT_COMPONENT
   238 #undef  FT_COMPONENT
   239 #define FT_COMPONENT  trace_list
   239 #define FT_COMPONENT  list
   240 
   240 
   241   /* documentation is in ftlist.h */
   241   /* documentation is in ftlist.h */
   242 
   242 
   243   FT_EXPORT_DEF( FT_ListNode )
   243   FT_EXPORT_DEF( FT_ListNode )
   244   FT_List_Find( FT_List  list,
   244   FT_List_Find( FT_List  list,