texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Patrice Dumas
Date: Sat, 11 Nov 2023 10:50:16 -0500 (EST)

branch: master
commit f342408f5c2150c73987cd45840f4b59ff7d128f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Nov 11 16:50:06 2023 +0100

    * tp/Texinfo/XS/convert/ConvertXS.xs
    (html_prepare_units_directions_files),
    tp/Texinfo/XS/convert/convert_html.c (html_destroy_files_source_info):
    free files_source_info.
    
    * tp/Texinfo/XS/convert/convert_html.c (html_set_pages_files): free
    top_node_filename_str, filename and output_unit_file_name file names
    setting loop, and unit_file_name_paths.
    
    * tp/Texinfo/XS/convert/convert_html.c (html_translate_names):
    free/destroy text or tree before replacing.
    
    * tp/Texinfo/XS/convert/convert_html.c
    (convert_output_output_unit_internal): free encoded_out_filepath.
    
    * tp/Texinfo/XS/main/output_unit.c (units_directions): use an
    ELEMENT_LIST for up_list instead of an ELEMENT, and free.
    
    * tp/Texinfo/XS/main/translations.c (replace_convert_substrings): free
    convert_to_texinfo debug string.
---
 ChangeLog                            | 23 +++++++++++++++++++++++
 tp/Texinfo/XS/convert/ConvertXS.xs   |  5 +++++
 tp/Texinfo/XS/convert/convert_html.c | 28 ++++++++++++++++++++++++++--
 tp/Texinfo/XS/convert/convert_html.h |  2 ++
 tp/Texinfo/XS/main/output_unit.c     | 12 +++++++-----
 tp/Texinfo/XS/main/translations.c    |  7 +++++--
 6 files changed, 68 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 88cd170c0e..a3140fb241 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2023-11-11  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs
+       (html_prepare_units_directions_files),
+       tp/Texinfo/XS/convert/convert_html.c (html_destroy_files_source_info):
+       free files_source_info.
+
+       * tp/Texinfo/XS/convert/convert_html.c (html_set_pages_files): free
+       top_node_filename_str, filename and output_unit_file_name file names
+       setting loop, and unit_file_name_paths.
+       
+       * tp/Texinfo/XS/convert/convert_html.c (html_translate_names):
+       free/destroy text or tree before replacing.
+
+       * tp/Texinfo/XS/convert/convert_html.c
+       (convert_output_output_unit_internal): free encoded_out_filepath.
+
+       * tp/Texinfo/XS/main/output_unit.c (units_directions): use an
+       ELEMENT_LIST for up_list instead of an ELEMENT, and free.
+
+       * tp/Texinfo/XS/main/translations.c (replace_convert_substrings): free
+       convert_to_texinfo debug string.
+
 2023-11-11  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/converter_types.h (HCC_CONTEXT_TYPES_LIST),
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index d3b6f3b844..1d710a13d5 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -396,6 +396,11 @@ html_prepare_units_directions_files (SV *converter_in, SV 
*output_units_in, SV *
          /* file names API */
          pass_output_unit_files (converter_in, &self->output_unit_files);
 
+         if (files_source_info)
+           {
+             html_destroy_files_source_info (files_source_info);
+           }
+
          RETVAL = files_source_info_sv;
     OUTPUT:
          RETVAL
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 452f504f42..d3c04ee545 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1637,6 +1637,18 @@ find_file_source_info (FILE_SOURCE_INFO_LIST 
*files_source_info,
   return 0;
 }
 
+void
+html_destroy_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info)
+{
+  int i;
+  for (i = 0; i < files_source_info->number; i++)
+    {
+      free (files_source_info->list[i].filename);
+    }
+  free (files_source_info->list);
+  free (files_source_info);
+}
+
 static char *
 add_to_unit_file_name_paths (char **unit_file_name_paths,
                              char *filename, OUTPUT_UNIT *output_unit)
@@ -1933,6 +1945,7 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST 
*output_units,
                                          output_unit_file_name,
                                          output_unit);
         }
+      free (top_node_filename_str);
     }
 
   self->output_unit_file_indices = (size_t *)
@@ -1944,7 +1957,7 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST 
*output_units,
       FILE_NAME_PATH_COUNTER *output_unit_file;
       OUTPUT_UNIT *output_unit = output_units->list[i];
       char *output_unit_file_name = unit_file_name_paths[i];
-      char *filename = output_unit_file_name;
+      char *filename = strdup (output_unit_file_name);
       FILE_SOURCE_INFO *file_source_info
         = find_file_source_info (files_source_info, output_unit_file_name);
       char *filepath = file_source_info->path;
@@ -1980,6 +1993,7 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST 
*output_units,
                                           file_name_path->filename,
                                           "special_file", "user_defined",
                                            0, file_name_path->filepath);
+              free (filename);
               filename = file_name_path->filename;
             }
           free (file_name_path);
@@ -1992,9 +2006,12 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST 
*output_units,
         fprintf (stderr, "Page %s: %s(%d)\n",
                  output_unit_texi (output_unit),
                  output_unit->unit_filename, output_unit_file->counter);
-
+      free (filename);
+      free (output_unit_file_name);
     }
 
+  free (unit_file_name_paths);
+
   if (special_units && special_units->number)
     {
       int i;
@@ -2943,6 +2960,7 @@ html_translate_names (CONVERTER *self)
                   && !format_spec->unset)
                 {
                   add_cmd = 1;
+                  free (format_spec->text);
                   format_spec->text
                    = html_gdt_string (format_spec->translated_converted, self,
                                  0, 0, 0);
@@ -2962,6 +2980,8 @@ html_translate_names (CONVERTER *self)
                   if (translated_tree)
                     {
                       add_cmd = 1;
+                      if (format_spec->tree)
+                        destroy_element_and_children (format_spec->tree);
 
                       format_spec->tree = translated_tree;
                     }
@@ -4053,6 +4073,7 @@ convert_output_output_unit_internal (CONVERTER *self,
           message_list_document_error (&self->error_messages, self->conf,
                              "could not open %s for writing: %s",
                              out_filepath, open_error_message);
+          free (encoded_out_filepath);
           return 0;
         }
 
@@ -4095,6 +4116,7 @@ convert_output_output_unit_internal (CONVERTER *self,
             { /* register error message instead? */
               fprintf (stderr, "ERROR: write to %s failed (%zu/%zu)\n",
                        encoded_out_filepath, write_len, res_len);
+              free (encoded_out_filepath);
               return 0;
             }
         }
@@ -4108,9 +4130,11 @@ convert_output_output_unit_internal (CONVERTER *self,
               message_list_document_error (&self->error_messages, self->conf,
                              "error on closing %s: %s",
                              out_filepath, strerror (errno));
+              free (encoded_out_filepath);
               return 0;
             }
         }
+      free (encoded_out_filepath);
     }
   return 1;
 }
diff --git a/tp/Texinfo/XS/convert/convert_html.h 
b/tp/Texinfo/XS/convert/convert_html.h
index db4f49e50d..7d9f2ce2c3 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -55,6 +55,8 @@ char *html_convert_output (CONVERTER *self, ELEMENT *root,
                            int special_units_descriptor,
                            char *output_file, char *destination_directory,
                            char *output_filename, char *document_name);
+
 void html_check_transfer_state_finalization (CONVERTER *self);
 void html_destroy (CONVERTER *self);
+void html_destroy_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info);
 #endif
diff --git a/tp/Texinfo/XS/main/output_unit.c b/tp/Texinfo/XS/main/output_unit.c
index c683140f3c..82842d7b60 100644
--- a/tp/Texinfo/XS/main/output_unit.c
+++ b/tp/Texinfo/XS/main/output_unit.c
@@ -559,15 +559,16 @@ units_directions (OPTIONS *customization_information,
               else if (node_directions && node_directions->contents.list[D_up])
                 {
                   ELEMENT *up = node_directions->contents.list[D_up];
-                  ELEMENT *up_list = new_element (ET_NONE);
-                  add_to_contents_as_array (up_list, node);
+                  ELEMENT_LIST up_list;
+                  memset (&up_list, 0, sizeof (ELEMENT_LIST));
+                  add_to_element_list (&up_list, node);
                   while (1)
                     {
                       ELEMENT *up_node_directions;
                       int i;
                       int in_up = 0;
-                      for (i = 0; i < up_list->contents.number; i++)
-                        if (up == up_list->contents.list[i])
+                      for (i = 0; i < up_list.number; i++)
+                        if (up == up_list.list[i])
                           {
                             in_up = 1;
                             break;
@@ -585,13 +586,14 @@ units_directions (OPTIONS *customization_information,
                               up_node_directions->contents.list[D_next]);
                            break;
                         }
-                      add_to_contents_as_array (up_list, up);
+                      add_to_element_list (&up_list, up);
                       if (up_node_directions
                           && up_node_directions->contents.list[D_up])
                         up = up_node_directions->contents.list[D_up];
                       else
                         break;
                     }
+                  free (up_list.list);
                 }
             }
           if (directions[RUD_type_NodeForward]
diff --git a/tp/Texinfo/XS/main/translations.c 
b/tp/Texinfo/XS/main/translations.c
index b820299160..44dfb60a33 100644
--- a/tp/Texinfo/XS/main/translations.c
+++ b/tp/Texinfo/XS/main/translations.c
@@ -564,8 +564,11 @@ replace_convert_substrings (char *translated_string,
     }
 
 
-  debug("XS|RESULT GDT %d: '%s'\n", document_descriptor,
-                                          convert_to_texinfo (document->tree));
+  {
+    char *result_texi = convert_to_texinfo (document->tree);
+    debug("XS|RESULT GDT %d: '%s'\n", document_descriptor, result_texi);
+    free (result_texi);
+  }
 /*
 */
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]