/src/freetype/src/psnames/pspic.c
C | 94 lines | 54 code | 20 blank | 20 comment | 5 complexity | 0fbe329d6745bf905a5c719b6d92344d MD5 | raw file
1/***************************************************************************/ 2/* */ 3/* pspic.c */ 4/* */ 5/* The FreeType position independent code services for psnames module. */ 6/* */ 7/* Copyright 2009, 2010 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#ifdef FT_CONFIG_OPTION_PIC 26 27 /* forward declaration of PIC init functions from psmodule.c */ 28 FT_Error 29 FT_Create_Class_pscmaps_services( FT_Library library, 30 FT_ServiceDescRec** output_class ); 31 void 32 FT_Destroy_Class_pscmaps_services( FT_Library library, 33 FT_ServiceDescRec* clazz ); 34 35 void 36 FT_Init_Class_pscmaps_interface( FT_Library library, 37 FT_Service_PsCMapsRec* clazz ); 38 39 void 40 psnames_module_class_pic_free( FT_Library library ) 41 { 42 FT_PIC_Container* pic_container = &library->pic_container; 43 FT_Memory memory = library->memory; 44 45 46 if ( pic_container->psnames ) 47 { 48 PSModulePIC* container = (PSModulePIC*)pic_container->psnames; 49 50 51 if(container->pscmaps_services) 52 FT_Destroy_Class_pscmaps_services( library, 53 container->pscmaps_services ); 54 container->pscmaps_services = NULL; 55 FT_FREE( container ); 56 pic_container->psnames = NULL; 57 } 58 } 59 60 61 FT_Error 62 psnames_module_class_pic_init( FT_Library library ) 63 { 64 FT_PIC_Container* pic_container = &library->pic_container; 65 FT_Error error = PSnames_Err_Ok; 66 PSModulePIC* container; 67 FT_Memory memory = library->memory; 68 69 70 /* allocate pointer, clear and set global container pointer */ 71 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) 72 return error; 73 FT_MEM_SET( container, 0, sizeof ( *container ) ); 74 pic_container->psnames = container; 75 76 /* initialize pointer table - this is how the module usually expects this data */ 77 error = FT_Create_Class_pscmaps_services( 78 library, &container->pscmaps_services ); 79 if ( error ) 80 goto Exit; 81 FT_Init_Class_pscmaps_interface( library, 82 &container->pscmaps_interface ); 83 84Exit: 85 if ( error ) 86 psnames_module_class_pic_free( library ); 87 return error; 88 } 89 90 91#endif /* FT_CONFIG_OPTION_PIC */ 92 93 94/* END */