Home | History | Annotate | Download | only in psnames
      1 /***************************************************************************/
      2 /*                                                                         */
      3 /*  pspic.c                                                                */
      4 /*                                                                         */
      5 /*    The FreeType position independent code services for psnames module.  */
      6 /*                                                                         */
      7 /*  Copyright 2009-2018 by                                                 */
      8 /*  Oran Agra and Mickey Gabel.                                            */
      9 /*                                                                         */
     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      */
     12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
     13 /*  this file you indicate that you have read the license and              */
     14 /*  understand and accept it fully.                                        */
     15 /*                                                                         */
     16 /***************************************************************************/
     17 
     18 
     19 #include <ft2build.h>
     20 #include FT_FREETYPE_H
     21 #include FT_INTERNAL_OBJECTS_H
     22 #include "pspic.h"
     23 #include "psnamerr.h"
     24 
     25 
     26 #ifdef FT_CONFIG_OPTION_PIC
     27 
     28   /* forward declaration of PIC init functions from psmodule.c */
     29   FT_Error
     30   FT_Create_Class_pscmaps_services( FT_Library           library,
     31                                     FT_ServiceDescRec**  output_class );
     32   void
     33   FT_Destroy_Class_pscmaps_services( FT_Library          library,
     34                                      FT_ServiceDescRec*  clazz );
     35 
     36   void
     37   FT_Init_Class_pscmaps_interface( FT_Library              library,
     38                                    FT_Service_PsCMapsRec*  clazz );
     39 
     40 
     41   void
     42   psnames_module_class_pic_free( FT_Library  library )
     43   {
     44     FT_PIC_Container*  pic_container = &library->pic_container;
     45     FT_Memory          memory        = library->memory;
     46 
     47 
     48     if ( pic_container->psnames )
     49     {
     50       PSModulePIC*  container = (PSModulePIC*)pic_container->psnames;
     51 
     52 
     53       if ( container->pscmaps_services )
     54         FT_Destroy_Class_pscmaps_services( library,
     55                                            container->pscmaps_services );
     56       container->pscmaps_services = NULL;
     57       FT_FREE( container );
     58       pic_container->psnames = NULL;
     59     }
     60   }
     61 
     62 
     63   FT_Error
     64   psnames_module_class_pic_init( FT_Library  library )
     65   {
     66     FT_PIC_Container*  pic_container = &library->pic_container;
     67     FT_Error           error         = FT_Err_Ok;
     68     PSModulePIC*       container     = NULL;
     69     FT_Memory          memory        = library->memory;
     70 
     71 
     72     /* allocate pointer, clear and set global container pointer */
     73     if ( FT_ALLOC( container, sizeof ( *container ) ) )
     74       return error;
     75     FT_MEM_SET( container, 0, sizeof ( *container ) );
     76     pic_container->psnames = container;
     77 
     78     /* initialize pointer table -                       */
     79     /* this is how the module usually expects this data */
     80     error = FT_Create_Class_pscmaps_services(
     81               library, &container->pscmaps_services );
     82     if ( error )
     83       goto Exit;
     84     FT_Init_Class_pscmaps_interface( library,
     85                                      &container->pscmaps_interface );
     86 
     87   Exit:
     88     if ( error )
     89       psnames_module_class_pic_free( library );
     90     return error;
     91   }
     92 
     93 
     94 #endif /* FT_CONFIG_OPTION_PIC */
     95 
     96 
     97 /* END */
     98