--- psiconv/trunk/lib/psiconv/generate_common.c 2004/02/26 15:58:48 232 +++ psiconv/trunk/lib/psiconv/generate_common.c 2004/02/26 16:27:43 233 @@ -77,7 +77,7 @@ goto ERROR; for (i = 0; i < psiconv_list_length(value); i++) { if (!(entry = psiconv_list_get(value,i))) { - psiconv_error(config,lev+1,0,"Massive memory corruption"); + psiconv_error(config,lev+1,0,"Data structure corruption"); res = -PSICONV_E_NOMEM; goto ERROR; } @@ -129,12 +129,13 @@ if (psiconv_list_length(value)) { if (!(extra_buf = psiconv_buffer_new())) { + psiconv_error(config,lev+1,0,"Out of memory error"); res = -PSICONV_E_NOMEM; goto ERROR; } for (i = 0; i < psiconv_list_length(value); i++) { if (!(paragraph = psiconv_list_get(value,i))) { - psiconv_error(config,lev+1,0,"Massive memory corruption"); + psiconv_error(config,lev+1,0,"Data structure corruption"); res = -PSICONV_E_NOMEM; goto ERROR; } @@ -194,33 +195,38 @@ } if (!(paragraph_type_list = psiconv_list_new(sizeof(new_type)))) { + psiconv_error(config,lev+1,0,"Out of memory error"); res = -PSICONV_E_NOMEM; goto ERROR1; } if (!(buf_types = psiconv_buffer_new())) { + psiconv_error(config,lev+1,0,"Out of memory error"); res = -PSICONV_E_NOMEM; goto ERROR2; } if (!(buf_elements = psiconv_buffer_new())) { + psiconv_error(config,lev+1,0,"Out of memory error"); res = -PSICONV_E_NOMEM; goto ERROR3; } if (!(buf_inlines = psiconv_buffer_new())) { + psiconv_error(config,lev+1,0,"Out of memory error"); res = -PSICONV_E_NOMEM; goto ERROR4; } if (!(buf_objects = psiconv_buffer_new())) { + psiconv_error(config,lev+1,0,"Out of memory error"); res = -PSICONV_E_NOMEM; goto ERROR5; } for (i = 0; i < psiconv_list_length(value); i++) { if (!(paragraph = psiconv_list_get(value,i))) { - psiconv_error(config,lev+1,0,"Massive memory corruption"); + psiconv_error(config,lev+1,0,"Data structure corruption"); res = -PSICONV_E_NOMEM; goto ERROR6; } @@ -231,6 +237,7 @@ /* We need it for the next if-statement */ if (psiconv_list_length(paragraph->in_lines) == 1) if (!(in_line = psiconv_list_get(paragraph->in_lines,1))) { + psiconv_error(config,lev+1,0,"Data structure corruption"); res = -PSICONV_E_NOMEM; goto ERROR6; } @@ -263,7 +270,7 @@ for (j = 0; j < psiconv_list_length(paragraph->in_lines); j++) { nr_of_inlines ++; if (!(in_line = psiconv_list_get(paragraph->in_lines,j))) { - psiconv_error(config,lev,0,"Massive memory corruption"); + psiconv_error(config,lev,0,"Data structure corruption"); res = -PSICONV_E_NOMEM; goto ERROR6; } @@ -275,6 +282,7 @@ complete length of all inlines equals the text length */ if (j == psiconv_list_length(paragraph->in_lines)-1) { if (paralen > psiconv_unicode_strlen(paragraph->text)+1) { + psiconv_error(config,lev+1,0,"Inline formatting data length and line length are inconsistent"); res = -PSICONV_E_GENERATE; goto ERROR6; } @@ -290,10 +298,14 @@ if ((res = psiconv_write_u32(config,buf_inlines,lev+1,PSICONV_ID_OBJECT))) goto ERROR6; obj_id = psiconv_buffer_unique_id(); - if ((res = psiconv_buffer_add_reference(buf_inlines,obj_id))) + if ((res = psiconv_buffer_add_reference(buf_inlines,obj_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; - if ((res = psiconv_buffer_add_target(buf_objects,obj_id))) + } + if ((res = psiconv_buffer_add_target(buf_objects,obj_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; + } if ((res = psiconv_write_embedded_object_section(config,buf_objects,lev+1, in_line->object))) goto ERROR6; @@ -311,7 +323,7 @@ para_charlayout = paragraph->base_character; else { if (!(in_line = psiconv_list_get(paragraph->in_lines,0))) { - psiconv_error(config,lev,0,"Massive memory corruption"); + psiconv_error(config,lev,0,"Data structure corruption"); res = -PSICONV_E_NOMEM; goto ERROR6; } @@ -319,7 +331,7 @@ } for (j = 0; j < psiconv_list_length(paragraph_type_list); j++) { if (!(paragraph_type = psiconv_list_get(paragraph_type_list,j))) { - psiconv_error(config,lev,0,"Massive memory corruption"); + psiconv_error(config,lev,0,"Data structure corruption"); res = -PSICONV_E_NOMEM; goto ERROR6; } @@ -340,8 +352,10 @@ new_type.character = para_charlayout; new_type.style = paragraph->base_style; paragraph_type = &new_type; - if ((res = psiconv_list_add(paragraph_type_list,paragraph_type))) + if ((res = psiconv_list_add(paragraph_type_list,paragraph_type))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; + } if ((res = psiconv_write_u32(config,buf_types,lev+1,paragraph_type->nr))) goto ERROR6; if (!(style = psiconv_get_style(styles,paragraph_type->style))) { @@ -392,18 +406,26 @@ goto ERROR6; if ((res = psiconv_write_u8(config,buf,lev+1, ptl_length))) goto ERROR6; - if ((res = psiconv_buffer_concat(buf,buf_types))) + if ((res = psiconv_buffer_concat(buf,buf_types))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; + } if ((res = psiconv_write_u32(config,buf,lev+1,pel_length))) goto ERROR6; - if ((res = psiconv_buffer_concat(buf,buf_elements))) + if ((res = psiconv_buffer_concat(buf,buf_elements))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; + } if ((res = psiconv_write_u32(config,buf,lev+1,nr_of_inlines))) goto ERROR6; - if ((res = psiconv_buffer_concat(buf,buf_inlines))) + if ((res = psiconv_buffer_concat(buf,buf_inlines))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; - if ((res = psiconv_buffer_concat(buf,buf_objects))) + } + if ((res = psiconv_buffer_concat(buf,buf_objects))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; + } ERROR6: psiconv_buffer_free(buf_objects); @@ -449,22 +471,34 @@ psiconv_word_styles_section styles_section; psiconv_progress(config,lev,0,"Writing styleless layout section"); - if (!(styles_section = malloc(sizeof(*styles_section)))) + if (!(styles_section = malloc(sizeof(*styles_section)))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR1; - if (!(styles_section->normal = malloc(sizeof(*styles_section->normal)))) + } + if (!(styles_section->normal = malloc(sizeof(*styles_section->normal)))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } if (!(styles_section->normal->character = - psiconv_clone_character_layout(base_char))) + psiconv_clone_character_layout(base_char))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR3; + } if (!(styles_section->normal->paragraph = - psiconv_clone_paragraph_layout(base_para))) + psiconv_clone_paragraph_layout(base_para))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR4; + } styles_section->normal->hotkey = 0; - if (!(styles_section->normal->name = psiconv_unicode_empty_string())) + if (!(styles_section->normal->name = psiconv_unicode_empty_string())) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR5; + } if (!(styles_section->styles = psiconv_list_new(sizeof( - struct psiconv_word_style_s)))) + struct psiconv_word_style_s)))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR6; + } res = psiconv_write_layout_section(config,buf,lev+1,value,styles_section,0); psiconv_free_word_styles_section(styles_section); @@ -506,6 +540,7 @@ } if (!(extra_buf = psiconv_buffer_new())) { + psiconv_error(config,lev+1,0,"Out of memory error"); res = -PSICONV_E_NOMEM; goto ERROR1; } @@ -517,27 +552,39 @@ goto ERROR2; if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_DISPLAY_SECTION))) goto ERROR2; - if ((res = psiconv_buffer_add_reference(buf,display_id))) + if ((res = psiconv_buffer_add_reference(buf,display_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_ICON_SECTION))) goto ERROR2; - if ((res = psiconv_buffer_add_reference(buf,icon_id))) + if ((res = psiconv_buffer_add_reference(buf,icon_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_OBJECT_SECTION_TABLE_SECTION))) goto ERROR2; - if ((res = psiconv_buffer_add_reference(buf,table_id))) + if ((res = psiconv_buffer_add_reference(buf,table_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } - if ((res = psiconv_buffer_add_target(buf,display_id))) + if ((res = psiconv_buffer_add_target(buf,display_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } if ((res = psiconv_write_object_display_section(config,buf,lev+1,value->display))) goto ERROR2; - if ((res = psiconv_buffer_add_target(buf,icon_id))) + if ((res = psiconv_buffer_add_target(buf,icon_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } if ((res = psiconv_write_object_icon_section(config,buf,lev+1,value->icon))) goto ERROR2; - if ((res = psiconv_buffer_add_target(buf,table_id))) + if ((res = psiconv_buffer_add_target(buf,table_id))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } switch(value->object->type) { case psiconv_word_file: if ((res = psiconv_write_word_file(config,extra_buf,lev+1, @@ -562,10 +609,14 @@ goto ERROR2; } - if ((res = psiconv_buffer_resolve(extra_buf))) + if ((res = psiconv_buffer_resolve(extra_buf))) { + psiconv_error(config,lev+1,0,"Internal error resolving buffer references"); goto ERROR2; - if ((res = psiconv_buffer_concat(buf,extra_buf))) + } + if ((res = psiconv_buffer_concat(buf,extra_buf))) { + psiconv_error(config,lev+1,0,"Out of memory error"); goto ERROR2; + } psiconv_buffer_free(extra_buf); psiconv_progress(config,lev,0,"End of embedded object section");