Debian Codegraph @

texk/web2c/luatexdir/font/mapfile.c

raw
1 /*
2
3 Copyright 1996-2006 Han The Thanh <[email protected]>
4 Copyright 2006-2010 Taco Hoekwater <[email protected]>
5
6 This file is part of LuaTeX.
7
8 LuaTeX is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your
11 option) any later version.
12
13 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
20
21 */
22
23 #include "ptexlib.h"
24 #include <math.h>
25 #include <kpathsea/c-auto.h>
26 #include <kpathsea/c-memstr.h>
27 #include <string.h>
28
29 #define FM_BUF_SIZE 1024
30
31 static FILE *fm_file;
32
33 static unsigned char *fm_buffer = NULL;
34 static int fm_size = 0;
35 static int fm_curbyte = 0;
36
37 #define fm_open(a) (fm_file = fopen((char *)(a), FOPEN_RBIN_MODE))
38 #define fm_read_file() readbinfile(fm_file,&fm_buffer,&fm_size)
39 #define fm_close() xfclose(fm_file, cur_file_name)
40 #define fm_getchar() fm_buffer[fm_curbyte++]
41 #define fm_eof() (fm_curbyte>fm_size)
42 #define is_cfg_comment(c) (c == 10 || c == '*' || c == '#' || c == ';' || c == '%')
43
44 typedef enum { FM_DUPIGNORE, FM_REPLACE, FM_DELETE } updatemode;
45
46 typedef struct mitem {
47 /*tex |FM_DUPIGNORE| or |FM_REPLACE| or |FM_DELETE| */
48 updatemode mode;
49 /*tex map file or map line */
50 maptype type;
51 /*tex pointer to map file name or map line */
52 char *line;
53 /*tex line number in map file */
54 int lineno;
55 } mapitem;
56
57 mapitem *mitem = NULL;
58
59 #define read_field(r, q, buf) do { \
60 q = buf; \
61 while (*r != ' ' && *r != '<' && *r != '"' && *r != '\0') \
62 *q++ = *r++; \
63 *q = '\0'; \
64 skip_char(r, ' '); \
65 } while (0)
66
67 #define set_field(F) do { \
68 if (q > buf) \
69 fm->F = xstrdup(buf); \
70 if (*r == '\0') \
71 goto done; \
72 } while (0)
73
74 fm_entry *new_fm_entry(void)
75 {
76 fm_entry *fm;
77 fm = xtalloc(1, fm_entry);
78 fm->tfm_name = NULL;
79 fm->ps_name = NULL;
80 fm->fd_flags = FD_FLAGS_NOT_SET_IN_MAPLINE;
81 fm->ff_name = NULL;
82 fm->encname = NULL;
83 fm->subfont = 0;
84 fm->type = 0;
85 fm->slant = 0;
86 fm->extend = 1000;
87 unset_slantset(fm);
88 unset_extendset(fm);
89 unset_inuse(fm);
90 return fm;
91 }
92
93 void delete_fm_entry(fm_entry * fm)
94 {
95 xfree(fm->tfm_name);
96 xfree(fm->ps_name);
97 xfree(fm->ff_name);
98 xfree(fm);
99 }
100
101 static ff_entry *new_ff_entry(void)
102 {
103 ff_entry *ff;
104 ff = xtalloc(1, ff_entry);
105 ff->ff_name = NULL;
106 ff->ff_path = NULL;
107 return ff;
108 }
109
110 static void delete_ff_entry(ff_entry * ff)
111 {
112 xfree(ff->ff_name);
113 xfree(ff->ff_path);
114 xfree(ff);
115 }
116
117 static struct avl_table *tfm_tree = NULL;
118 static struct avl_table *ff_tree = NULL;
119 static struct avl_table *encname_tree = NULL;
120
121 /*tex
122
123 We sort |fm_entry| into |tfm_tree| by |tfm_name|:
124
125 */
126
127 static int comp_fm_entry_tfm(const void *pa, const void *pb, void *p)
128 {
129 (void) p;
130 return strcmp(((const fm_entry *) pa)->tfm_name, ((const fm_entry *) pb)->tfm_name);
131 }
132
133 /* We sort |ff_entry| into |ff_tree| by |ff_name|: */
134
135 static int comp_ff_entry(const void *pa, const void *pb, void *p)
136 {
137 (void) p;
138 return strcmp(((const ff_entry *) pa)->ff_name, ((const ff_entry *) pb)->ff_name);
139 }
140
141 static void create_avl_trees(void)
142 {
143 tfm_tree = avl_create(comp_fm_entry_tfm, NULL, &avl_xallocator);
144 ff_tree = avl_create(comp_ff_entry, NULL, &avl_xallocator);
145 encname_tree = avl_create(comp_string_entry, NULL, &avl_xallocator);
146 }
147
148 int avl_do_entry(fm_entry * fm, int mode)
149 {
150 fm_entry *p;
151 void *a;
152 void **aa;
153 int delete_new = 0;
154 if (tfm_tree == NULL)
155 create_avl_trees();
156 p = (fm_entry *) avl_find(tfm_tree, fm);
157 if (p != NULL) {
158 switch (mode) {
159 case FM_DUPIGNORE:
160 formatted_warning("map file", "entry for '%s' already exists, duplicates ignored", fm->tfm_name);
161 delete_new = 1;
162 break;
163 case FM_REPLACE:
164 case FM_DELETE:
165 if (is_inuse(p)) {
166 formatted_warning("map file", "entry for '%s' has been used, replace/delete not allowed", fm->tfm_name);
167 delete_new = 1;
168 } else {
169 a = avl_delete(tfm_tree, p);
170 assert(a != NULL);
171 delete_fm_entry(p);
172 }
173 break;
174 default:
175 formatted_error("map file", "something bad happened",0);
176 }
177 }
178 if ((mode == FM_DUPIGNORE || mode == FM_REPLACE) && delete_new == 0) {
179 aa = avl_probe(tfm_tree, fm);
180 if (aa == NULL) {
181 /*tex Is this a problem? */
182 }
183 } else
184 delete_new = 1;
185 return delete_new;
186 }
187
188 /*tex
189
190 Add the encoding name to an AVL tree. This has nothing to do with |writeenc.c|.
191
192 */
193
194 static char *add_encname(char *s)
195 {
196 char *p;
197 void **aa;
198 if ((p = (char *) avl_find(encname_tree, s)) == NULL) {
199 /*tex The encoding name has not yet been registered. */
200 p = xstrdup(s);
201 aa = avl_probe(encname_tree, p);
202 if (aa == NULL) {
203 /*tex Is this a problem? */
204 }
205 }
206 return p;
207 }
208
209 /*tex
210
211 A consistency check for map entry, with warn flag.
212
213 */
214
215 static int check_fm_entry(fm_entry * fm, boolean warn)
216 {
217 int a = 0;
218 if (is_fontfile(fm) && !is_included(fm)) {
219 if (warn)
220 formatted_warning("map file",
221 "ambiguous entry for '%s': font file present but not included, "
222 "will be treated as font file not present", fm->tfm_name);
223 xfree(fm->ff_name);
224 /*tex Do not set variable |a| as this entry will be still accepted. */
225 }
226 /*tex If both ps_name and font file are missing, drop this entry. */
227 if (fm->ps_name == NULL && !is_fontfile(fm)) {
228 if (warn)
229 formatted_warning("map file", "invalid entry for '%s': both ps_name and font file missing", fm->tfm_name);
230 a += 1;
231 }
232 /*tex \TRUETYPE\ fonts cannot be reencoded without subsetting. */
233 if (is_truetype(fm) && is_reencoded(fm) && !is_subsetted(fm)) {
234 if (warn)
235 formatted_warning("map file", "invalid entry for '%s': only subsetted TrueType font can be reencoded", fm->tfm_name);
236 a += 2;
237 }
238 /*tex The value of |SlantFont| and |ExtendFont| must be reasonable. */
239 if (fm->slant < FONT_SLANT_MIN || fm->slant > FONT_SLANT_MAX) {
240 if (warn)
241 formatted_warning("map file", "invalid entry for '%s': value '%g' is to large for SlantFont",
242 fm->tfm_name, fm->slant / 1000.0);
243 a += 8;
244 }
245 if (fm->extend < FONT_EXTEND_MIN || fm->extend > FONT_EXTEND_MAX) {
246 if (warn)
247 formatted_warning("map file", "invalid entry for '%s': value '%g' is too large for ExtendFont",
248 fm->tfm_name, fm->extend / 1000.0);
249 a += 16;
250 }
251 return a;
252 }
253
254 /*tex
255
256 Returns the font number if s is one of the 14 std. font names, -1 otherwise.
257 A bit speed trimmed. Using these base fonts is oldfashioned and doesn't
258 happen in a decent \LUATEX\ produced file.
259
260 */
261
262 int check_std_t1font(char *s)
263 {
264 static const char *std_t1font_names[] = {
265 "Courier", /* 0:7 */
266 "Courier-Bold", /* 1:12 */
267 "Courier-Oblique", /* 2:15 */
268 "Courier-BoldOblique", /* 3:19 */
269 "Helvetica", /* 4:9 */
270 "Helvetica-Bold", /* 5:14 */
271 "Helvetica-Oblique", /* 6:17 */
272 "Helvetica-BoldOblique", /* 7:21 */
273 "Symbol", /* 8:6 */
274 "Times-Roman", /* 9:11 */
275 "Times-Bold", /* 10:10 */
276 "Times-Italic", /* 11:12 */
277 "Times-BoldItalic", /* 12:16 */
278 "ZapfDingbats" /* 13:12 */
279 };
280 static const int index[] = {
281 -1, -1, -1, -1, -1, -1, 8, 0, -1, 4, 10,
282 9, -1, -1, 5, 2, 12, 6, -1, 3, -1, 7
283 };
284 size_t n;
285 int k = -1;
286 n = strlen(s);
287 if (n > 21)
288 return -1;
289 if (n == 12) {
290 /*tex three names have length 12 */
291 switch (*s) {
292 case 'C':
293 /*tex Courier-Bold */
294 k = 1;
295 break;
296 case 'T':
297 /*tex Times-Italic */
298 k = 11;
299 break;
300 case 'Z':
301 /*tex ZapfDingbats */
302 k = 13;
303 break;
304 default:
305 return -1;
306 }
307 } else
308 k = index[n];
309 if (k > -1 && !strcmp(std_t1font_names[k], s))
310 return k;
311 return -1;
312 }
313
314 static void fm_scan_line(void)
315 {
316 int a, b, c, j, u = 0, v = 0;
317 char cc;
318 float d;
319 fm_entry *fm;
320 char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE];
321 char *p, *q, *s;
322 char *r = NULL;
323 switch (mitem->type) {
324 case MAPFILE:
325 p = fm_line;
326 while (!fm_eof()) {
327 if (fm_curbyte == fm_size) {
328 fm_curbyte++;
329 cc = 10;
330 } else {
331 cc = (char) fm_getchar();
332 }
333 append_char_to_buf(cc, p, fm_line, FM_BUF_SIZE);
334 if (cc == 10)
335 break;
336 }
337 *(--p) = '\0';
338 r = fm_line;
339 break;
340 case MAPLINE:
341 /*tex Work on a string from |makecstring|. */
342 r = mitem->line;
343 break;
344 default:
345 assert(0);
346 }
347 if (*r == '\0' || is_cfg_comment(*r))
348 return;
349 fm = new_fm_entry();
350 read_field(r, q, buf);
351 set_field(tfm_name);
352 if (!isdigit((unsigned char)*r)) {
353 /*tex The 2nd field |ps_name| may not start with a digit. */
354 read_field(r, q, buf);
355 set_field(ps_name);
356 }
357 if (isdigit((unsigned char)*r)) {
358 /*tex Is the font descriptor |/Flags| given? */
359 for (s = r; isdigit((unsigned char)*s); s++);
360 if (*s == ' ' || *s == '"' || *s == '<' || *s == '\0') {
361 /*tex not e.g.\ |8r.enc| */
362 fm->fd_flags = atoi(r);
363 while (isdigit((unsigned char)*r))
364 r++;
365 }
366 }
367 /*tex Loop through specials, encoding, font file:*/
368 while (1) {
369 skip_char(r, ' ');
370 switch (*r) {
371 case '\0':
372 goto done;
373 case '"':
374 /*tex The pening quote. */
375 r++;
376 u = v = 0;
377 do {
378 skip_char(r, ' ');
379 if (sscanf(r, "%f %n", &d, &j) > 0) {
380 /*tex Jump behind number, eat also blanks, if any. */
381 s = r + j;
382 if (*(s - 1) == 'E' || *(s - 1) == 'e') {
383 /*tex e.g.\ |0.5ExtendFont|: |%f = 0.5E| */
384 s--;
385 }
386 if (str_prefix(s, "SlantFont")) {
387 /*tex Correct rounding also for negative numbers. */
388 d *= (float) 1000.0;
389 fm->slant = (int) (d > 0 ? d + 0.5 : d - 0.5);
390 set_slantset(fm);
391 r = s + strlen("SlantFont");
392 } else if (str_prefix(s, "ExtendFont")) {
393 d *= (float) 1000.0;
394 fm->extend = (int) (d > 0 ? d + 0.5 : d - 0.5);
395 set_extendset(fm);
396 r = s + strlen("ExtendFont");
397 } else {
398 /*tex unknown name, jump over it */
399 for (r = s; *r != ' ' && *r != '"' && *r != '\0'; r++);
400 c = *r;
401 *r = '\0';
402 formatted_warning("map file", "invalid entry for '%s': unknown name '%s' ignored", fm->tfm_name, s);
403 *r = (char) c;
404 }
405 } else
406 for (; *r != ' ' && *r != '"' && *r != '\0'; r++);
407 }
408 while (*r == ' ');
409 if (*r == '"') {
410 /*tex The closing quote. */
411 r++;
412 } else {
413 formatted_warning("map file", "invalid entry for '%s': closing quote missing", fm->tfm_name);
414 goto bad_line;
415 }
416 break;
417 case 'P':
418 /*tex Handle cases for sub fonts like |PidEid=3,1| */
419 formatted_warning("map file", "invalid entry for '%s': subfonts are not supported", fm->tfm_name);
420 goto bad_line;
421 break;
422 default:
423 /*tex Encoding or font file specification. */
424 a = b = 0;
425 if (*r == '<') {
426 a = *r++;
427 if (*r == '<' || *r == '[')
428 b = *r++;
429 }
430 read_field(r, q, buf);
431 /*tex Encoding, Formats: |8r.enc| or |<8r.enc| or |<[8r.enc| */
432 if (strlen(buf) > 4 && strcasecmp(strend(buf) - 4, ".enc") == 0) {
433 /*tex |u|, |v| used if intervening blank: |<< foo| */
434 fm->encname = add_encname(buf);
435 u = v = 0;
436 } else if (strlen(buf) > 0) {
437 /*tex
438
439 We get the file name given where possible formats are:
440
441 \starttabulate[|||]
442 \NC subsetting \NC \tpe {<cmr10.pfa} \NC \NR
443 \NC no subsetting \NC \tpe {<<cmr10.pfa} \NC \NR
444 \NC no embedding \NC \tpe {cmr10.pfa} \NC \NR
445 \stoptabulate
446
447 */
448 if (a == '<' || u == '<') {
449 set_included(fm);
450 if ((a == '<' && b == 0) || (a == 0 && v == 0)) {
451 set_subsetted(fm);
452 } else {
453 /*tex
454
455 Otherwise |b| equals |<| or |[| which means that we have no subsetting.
456 */
457 }
458 }
459 set_field(ff_name);
460 u = v = 0;
461 } else {
462 u = a;
463 v = b;
464 }
465 }
466 }
467 done:
468 if (fm->ps_name != NULL && (check_std_t1font(fm->ps_name) >= 0))
469 set_std_t1font(fm);
470 if (is_fontfile(fm) && strlen(fm_fontfile(fm)) > 3) {
471 if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".ttf") == 0)
472 set_truetype(fm);
473 else if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".ttc") == 0)
474 set_truetype(fm);
475 else if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".otf") == 0)
476 set_opentype(fm);
477 else
478 set_type1(fm);
479 } else {
480 /*tex Assume a builtin font is \TYPEONE\: */
481 set_type1(fm);
482 }
483 if (check_fm_entry(fm, true) != 0)
484 goto bad_line;
485 /*tex
486
487 Until here the map line has been completely scanned without errors; |fm|
488 points to a valid, freshly filled-out |fm_entry| structure. Now follows
489 the actual work of registering or deleting.
490
491 */
492 if (avl_do_entry(fm, mitem->mode) == 0)
493 return;
494 bad_line:
495 delete_fm_entry(fm);
496 }
497
498 static void fm_read_info(void)
499 {
500 int callback_id;
501 int file_opened = 0;
502
503 if (tfm_tree == NULL)
504 create_avl_trees();
505 if (mitem->line == NULL) {
506 /*tex There is nothing to do. */
507 return;
508 }
509 mitem->lineno = 1;
510 switch (mitem->type) {
511 case MAPFILE:
512 xfree(fm_buffer);
513 fm_curbyte = 0;
514 fm_size = 0;
515 cur_file_name = luatex_find_file(mitem->line, find_map_file_callback);
516 if (cur_file_name) {
517 callback_id = callback_defined(read_map_file_callback);
518 if (callback_id > 0) {
519 if (run_callback(callback_id, "S->bSd", cur_file_name,
520 &file_opened, &fm_buffer, &fm_size)) {
521 if (file_opened) {
522 if (fm_size > 0) {
523 recorder_record_input(cur_file_name);
524 report_start_file(filetype_map,cur_file_name);
525 while (!fm_eof()) {
526 fm_scan_line();
527 mitem->lineno++;
528 }
529 report_stop_file(filetype_map);
530 fm_file = NULL;
531 }
532 } else {
533 formatted_warning("map file", "cannot open font map file '%s'", cur_file_name);
534 }
535 } else {
536 formatted_warning("map file", "cannot open font map file '%s'", cur_file_name);
537 }
538 } else {
539 if (!fm_open(cur_file_name)) {
540 formatted_warning("map file", "cannot open font map file '%s'", cur_file_name);
541 } else {
542 fm_read_file();
543 report_start_file(filetype_map,cur_file_name);
544 recorder_record_input(cur_file_name);
545 while (!fm_eof()) {
546 fm_scan_line();
547 mitem->lineno++;
548 }
549 fm_close();
550 report_stop_file(filetype_map);
551 fm_file = NULL;
552 }
553 }
554 cur_file_name = NULL;
555 }
556 break;
557 case MAPLINE:
558 cur_file_name = NULL;
559 fm_scan_line();
560 break;
561 default:
562 assert(0);
563 }
564 /*tex Done with this line: */
565 mitem->line = NULL;
566 cur_file_name = NULL;
567 return;
568 }
569
570 fm_entry *getfontmap(char *tfm_name)
571 {
572 fm_entry *fm;
573 fm_entry tmp;
574 if (tfm_name == NULL) {
575 /*tex Wide \LUA\ loaded fonts may not have a name. */
576 return NULL;
577 }
578 if (tfm_tree == NULL) {
579 /*tex Only read the default map file. */
580 fm_read_info();
581 }
582 /*tex Look up the name. */
583 tmp.tfm_name = tfm_name;
584 fm = (fm_entry *) avl_find(tfm_tree, &tmp);
585 if (fm == NULL)
586 return NULL;
587 set_inuse(fm);
588 return fm;
589 }
590
591 /*tex
592
593 Process map file given by its name or map line contents. Items not beginning
594 with [+-=] flush default map file, if it has not yet been read. Leading
595 blanks and blanks immediately following [+-=] are ignored.
596
597 */
598
599 void process_map_item(char *s, int type)
600 {
601 char *p;
602 int mode;
603 if (*s == ' ') {
604 /*tex Ignore leading blanks: */
605 s++;
606 }
607 switch (*s) {
608 case '+':
609 /* +mapfile.map, +mapline: insert an entry, if it is not duplicate */
610 mode = FM_DUPIGNORE;
611 s++;
612 break;
613 case '=':
614 /* =mapfile.map, =mapline: try to replace an existing entry */
615 mode = FM_REPLACE;
616 s++;
617 break;
618 case '-':
619 /* -mapfile.map, -mapline: try to delete an entry */
620 mode = FM_DELETE;
621 s++;
622 break;
623 default:
624 /* like +, but also: flush the default map file name */
625 mode = FM_DUPIGNORE;
626 mitem->line = NULL;
627 }
628 if (*s == ' ') {
629 /*tex Ignore a blank after |[+-=]| */
630 s++;
631 }
632 /*tex The map item starts here. */
633 p = s;
634 switch (type) {
635 case MAPFILE:
636 /*tex Remove blank at the end. */
637 while (*p != '\0' && *p != ' ')
638 p++;
639 *p = '\0';
640 break;
641 case MAPLINE:
642 /*tex A blank at end is allowed. */
643 break;
644 default:
645 assert(0);
646 }
647 if (mitem->line != NULL) {
648 /*tex Read default map file first */
649 fm_read_info();
650 }
651 if (*s != '\0') {
652 /*tex Only if real item to process. */
653 mitem->mode = mode;
654 mitem->type = type;
655 mitem->line = s;
656 fm_read_info();
657 }
658 }
659
660 void pdfmapfile(int t)
661 {
662 char *s = tokenlist_to_cstring(t, true, NULL);
663 process_map_item(s, MAPFILE);
664 free(s);
665 }
666
667 void pdfmapline(int t)
668 {
669 char *s = tokenlist_to_cstring(t, true, NULL);
670 process_map_item(s, MAPLINE);
671 free(s);
672 }
673
674 void pdf_init_map_file(const char *map_name)
675 {
676 assert(mitem == NULL);
677 mitem = xtalloc(1, mapitem);
678 mitem->mode = FM_DUPIGNORE;
679 mitem->type = MAPFILE;
680 mitem->line = xstrdup(map_name);
681 }
682
683 /*tex
684
685 An early check whether a font file exists. Search tree |ff_tree| is used in
686 1st instance, as it may be faster than the |kpse_find_file|, and
687 |kpse_find_file| is called only once per font file name plus expansion
688 parameter. This might help keeping speed, if many \PDF\ pages with same fonts
689 are to be embedded (not that we deal with that fragile approach any longer in
690 \LUATEX).
691
692 The |ff_tree| contains only font files, which are actually needed, so this tree
693 typically is much smaller than the tfm_tree.
694
695 */
696
697 ff_entry *check_ff_exist(char *ff_name, boolean is_tt)
698 {
699 ff_entry *ff;
700 ff_entry tmp;
701 void **aa;
702 int callback_id;
703 char *filepath = NULL;
704 tmp.ff_name = ff_name;
705 ff = (ff_entry *) avl_find(ff_tree, &tmp);
706 if (ff == NULL) {
707 /*tex The name is not yet in the database. */
708 ff = new_ff_entry();
709 ff->ff_name = xstrdup(ff_name);
710 if (is_tt) {
711 callback_id = callback_defined(find_truetype_file_callback);
712 if (callback_id > 0) {
713 run_callback(callback_id, "S->S", ff_name, &filepath);
714 if (filepath && strlen(filepath) == 0)
715 filepath = NULL;
716 ff->ff_path = filepath;
717 } else {
718 ff->ff_path = kpse_find_file(ff_name, kpse_truetype_format, 0);
719 }
720 } else {
721 callback_id = callback_defined(find_type1_file_callback);
722 if (callback_id > 0) {
723 run_callback(callback_id, "S->S", ff_name, &filepath);
724 if (filepath && strlen(filepath) == 0)
725 filepath = NULL;
726 ff->ff_path = filepath;
727 } else {
728 ff->ff_path = kpse_find_file(ff_name, kpse_type1_format, 0);
729 }
730 }
731 aa = avl_probe(ff_tree, ff);
732 if (aa == NULL) {
733 /*tex Is this a problem? */
734 }
735 }
736 return ff;
737 }
738
739 int is_subsetable(fm_entry * fm)
740 {
741 assert(is_included(fm));
742 return is_subsetted(fm);
743 }
744
745 /*tex Cleaning up: */
746
747 static void destroy_fm_entry_tfm(void *pa, void *pb)
748 {
749 fm_entry *fm;
750 (void) pb;
751 fm = (fm_entry *) pa;
752 delete_fm_entry(fm);
753 }
754
755 static void destroy_ff_entry(void *pa, void *pb)
756 {
757 ff_entry *ff;
758 (void) pb;
759 ff = (ff_entry *) pa;
760 delete_ff_entry(ff);
761 }
762
763 void fm_free(void)
764 {
765 if (tfm_tree != NULL) {
766 avl_destroy(tfm_tree, destroy_fm_entry_tfm);
767 tfm_tree = NULL;
768 }
769 if (ff_tree != NULL) {
770 avl_destroy(ff_tree, destroy_ff_entry);
771 ff_tree = NULL;
772 }
773 }