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