--- psiconv/trunk/lib/psiconv/data.c 1999/10/03 21:10:47 2 +++ psiconv/trunk/lib/psiconv/data.c 1999/10/27 15:05:03 20 @@ -18,6 +18,7 @@ */ #include "config.h" +#include "compat.h" #include #include #include "data.h" @@ -32,21 +33,28 @@ static void psiconv_free_style_aux(void *style); static void psiconv_free_in_line_layout_aux(void * layout); static void psiconv_free_paragraph_aux(void * paragraph); +static void psiconv_free_paint_data_section_aux(void * section); psiconv_character_layout psiconv_basic_character_layout(void) { - struct psiconv_color black = + /* Make the structures static, to oblige IRIX */ + static struct psiconv_color black = { 0x00, /* red */ 0x00, /* green */ 0x00, /* blue */ }; - struct psiconv_color white = + static struct psiconv_color white = { 0xff, /* red */ 0xff, /* green */ 0xff, /* blue */ }; + static struct psiconv_font font = + { + "Times New Roman", /* name */ + 3 /* screenfont */ + }; struct psiconv_character_layout cl = { &black, /* color */ @@ -60,48 +68,35 @@ NULL, /* font */ }; - cl.color = malloc(sizeof(*cl.color)); - cl.color->red = 0x00; - cl.color->green = 0x00; - cl.color->blue = 0x00; - cl.back_color = malloc(sizeof(*cl.color)); - cl.back_color->red = 0xff; - cl.back_color->green = 0xff; - cl.back_color->blue = 0xff; - cl.font = malloc(sizeof(*cl.font)); - cl.font->name = strdup("Times New Roman"); - cl.font->screenfont = 3; return psiconv_clone_character_layout(&cl); } psiconv_paragraph_layout psiconv_basic_paragraph_layout(void) { - char base_font[] = "Times New Roman"; - - struct psiconv_font font = + static struct psiconv_font font = { - base_font, /* name */ + "Times New Roman", /* name */ 2 /* screenfont */ }; - struct psiconv_color black = + static struct psiconv_color black = { 0x00, /* red */ 0x00, /* green */ 0x00, /* blue */ }; - struct psiconv_color white = + static struct psiconv_color white = { 0xff, /* red */ 0xff, /* green */ 0xff, /* blue */ }; - struct psiconv_border no_border = + static struct psiconv_border no_border = { psiconv_border_none, /* kind */ 1, /* thickness */ &black /* color */ }; - struct psiconv_bullet bullet = + static struct psiconv_bullet bullet = { psiconv_bool_false, /* on */ 10.0, /* font_size */ @@ -110,7 +105,7 @@ &black, /* color */ &font, /* font */ }; - struct psiconv_all_tabs tabs = + static struct psiconv_all_tabs tabs = { 0.64, /* normal */ NULL /* kind */ @@ -455,11 +450,62 @@ } } +void psiconv_free_texted_f(psiconv_texted_f file) +{ + if (file) { + psiconv_free_page_layout_section(file->page_sec); + psiconv_free_texted_section(file->texted_sec); + free(file); + } +} + +void psiconv_free_paint_data_section_aux(void * section) +{ + if (((psiconv_paint_data_section) section)->red) + free(((psiconv_paint_data_section)section) -> red); + if (((psiconv_paint_data_section) section)->green) + free(((psiconv_paint_data_section)section) -> green); + if (((psiconv_paint_data_section) section)->blue) + free(((psiconv_paint_data_section)section) -> blue); +} + +void psiconv_free_paint_data_section(psiconv_paint_data_section section) +{ + if (section) { + psiconv_free_paint_data_section_aux(section); + free(section); + } +} + +void psiconv_free_pictures(psiconv_pictures section) +{ + if (section) + psiconv_list_free_el(section,&psiconv_free_paint_data_section_aux); +} + +void psiconv_free_mbm_jumptable_section (psiconv_mbm_jumptable_section section) +{ + if (section) + psiconv_list_free(section); +} + +void psiconv_free_mbm_f(psiconv_mbm_f file) +{ + if (file) { + psiconv_free_pictures(file->sections); + free(file); + } +} + void psiconv_free_file(psiconv_file file) { if (file) { if (file->type == psiconv_word_file) psiconv_free_word_f((psiconv_word_f) file->file); + else if (file->type == psiconv_texted_file) + psiconv_free_texted_f((psiconv_texted_f) file->file); + else if (file->type == psiconv_mbm_file) + psiconv_free_mbm_f((psiconv_mbm_f) file->file); free(file); } }