/src/freetype/src/psnames/pspic.c

https://bitbucket.org/cabalistic/ogredeps/ · 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. #include <ft2build.h>
  18. #include FT_FREETYPE_H
  19. #include FT_INTERNAL_OBJECTS_H
  20. #include "pspic.h"
  21. #include "psnamerr.h"
  22. #ifdef FT_CONFIG_OPTION_PIC
  23. /* forward declaration of PIC init functions from psmodule.c */
  24. FT_Error
  25. FT_Create_Class_pscmaps_services( FT_Library library,
  26. FT_ServiceDescRec** output_class );
  27. void
  28. FT_Destroy_Class_pscmaps_services( FT_Library library,
  29. FT_ServiceDescRec* clazz );
  30. void
  31. FT_Init_Class_pscmaps_interface( FT_Library library,
  32. FT_Service_PsCMapsRec* clazz );
  33. void
  34. psnames_module_class_pic_free( FT_Library library )
  35. {
  36. FT_PIC_Container* pic_container = &library->pic_container;
  37. FT_Memory memory = library->memory;
  38. if ( pic_container->psnames )
  39. {
  40. PSModulePIC* container = (PSModulePIC*)pic_container->psnames;
  41. if(container->pscmaps_services)
  42. FT_Destroy_Class_pscmaps_services( library,
  43. container->pscmaps_services );
  44. container->pscmaps_services = NULL;
  45. FT_FREE( container );
  46. pic_container->psnames = NULL;
  47. }
  48. }
  49. FT_Error
  50. psnames_module_class_pic_init( FT_Library library )
  51. {
  52. FT_PIC_Container* pic_container = &library->pic_container;
  53. FT_Error error = PSnames_Err_Ok;
  54. PSModulePIC* container;
  55. FT_Memory memory = library->memory;
  56. /* allocate pointer, clear and set global container pointer */
  57. if ( FT_ALLOC ( container, sizeof ( *container ) ) )
  58. return error;
  59. FT_MEM_SET( container, 0, sizeof ( *container ) );
  60. pic_container->psnames = container;
  61. /* initialize pointer table - this is how the module usually expects this data */
  62. error = FT_Create_Class_pscmaps_services(
  63. library, &container->pscmaps_services );
  64. if ( error )
  65. goto Exit;
  66. FT_Init_Class_pscmaps_interface( library,
  67. &container->pscmaps_interface );
  68. Exit:
  69. if ( error )
  70. psnames_module_class_pic_free( library );
  71. return error;
  72. }
  73. #endif /* FT_CONFIG_OPTION_PIC */
  74. /* END */