OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2012 Google, Inc. | 2 * Copyright © 2012 Google, Inc. |
3 * | 3 * |
4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 if (unlikely (!shapers)) | 58 if (unlikely (!shapers)) |
59 { | 59 { |
60 char *env = getenv ("HB_SHAPER_LIST"); | 60 char *env = getenv ("HB_SHAPER_LIST"); |
61 if (!env || !*env) { | 61 if (!env || !*env) { |
62 (void) hb_atomic_ptr_cmpexch (&static_shapers, NULL, &all_shapers[0]); | 62 (void) hb_atomic_ptr_cmpexch (&static_shapers, NULL, &all_shapers[0]); |
63 return (const hb_shaper_pair_t *) all_shapers; | 63 return (const hb_shaper_pair_t *) all_shapers; |
64 } | 64 } |
65 | 65 |
66 /* Not found; allocate one. */ | 66 /* Not found; allocate one. */ |
67 shapers = (hb_shaper_pair_t *) malloc (sizeof (all_shapers)); | 67 shapers = (hb_shaper_pair_t *) calloc (1, sizeof (all_shapers)); |
68 if (unlikely (!shapers)) { | 68 if (unlikely (!shapers)) { |
69 (void) hb_atomic_ptr_cmpexch (&static_shapers, NULL, &all_shapers[0]); | 69 (void) hb_atomic_ptr_cmpexch (&static_shapers, NULL, &all_shapers[0]); |
70 return (const hb_shaper_pair_t *) all_shapers; | 70 return (const hb_shaper_pair_t *) all_shapers; |
71 } | 71 } |
72 | 72 |
73 memcpy (shapers, all_shapers, sizeof (all_shapers)); | 73 memcpy (shapers, all_shapers, sizeof (all_shapers)); |
74 | 74 |
75 /* Reorder shaper list to prefer requested shapers. */ | 75 /* Reorder shaper list to prefer requested shapers. */ |
76 unsigned int i = 0; | 76 unsigned int i = 0; |
77 char *end, *p = env; | 77 char *end, *p = env; |
(...skipping 24 matching lines...) Expand all Loading... |
102 goto retry; | 102 goto retry; |
103 } | 103 } |
104 | 104 |
105 #ifdef HB_USE_ATEXIT | 105 #ifdef HB_USE_ATEXIT |
106 atexit (free_static_shapers); /* First person registers atexit() callback. *
/ | 106 atexit (free_static_shapers); /* First person registers atexit() callback. *
/ |
107 #endif | 107 #endif |
108 } | 108 } |
109 | 109 |
110 return shapers; | 110 return shapers; |
111 } | 111 } |
OLD | NEW |