texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/tree.c (new_list, destroy_li


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/tree.c (new_list, destroy_list), tp/Texinfo/XS/structuring_transfo/transformations.c (modify_tree) (protect_text, protect_hashchar_at_line_beginning_internal) (reference_to_arg_internal): add new_list and destroy_list, use those functions.
Date: Sun, 12 Nov 2023 10:22:42 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new e803120b77 * tp/Texinfo/XS/main/tree.c (new_list, destroy_list), 
tp/Texinfo/XS/structuring_transfo/transformations.c (modify_tree) 
(protect_text, protect_hashchar_at_line_beginning_internal) 
(reference_to_arg_internal): add new_list and destroy_list, use those functions.
e803120b77 is described below

commit e803120b77d5004a88a3d8e12195fdaa9591fc22
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 12 16:22:36 2023 +0100

    * tp/Texinfo/XS/main/tree.c (new_list, destroy_list),
    tp/Texinfo/XS/structuring_transfo/transformations.c (modify_tree)
    (protect_text, protect_hashchar_at_line_beginning_internal)
    (reference_to_arg_internal): add new_list and destroy_list, use those
    functions.
---
 ChangeLog                                          |  8 ++++++++
 tp/Texinfo/XS/main/tree.c                          | 15 +++++++++++++++
 tp/Texinfo/XS/main/tree.h                          |  2 ++
 .../XS/structuring_transfo/transformations.c       | 22 +++++++---------------
 4 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c65efc93a5..9a832aa374 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-11-12  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/tree.c (new_list, destroy_list),
+       tp/Texinfo/XS/structuring_transfo/transformations.c (modify_tree)
+       (protect_text, protect_hashchar_at_line_beginning_internal)
+       (reference_to_arg_internal): add new_list and destroy_list, use those
+       functions.
+
 2023-11-12  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/tree.c (insert_list_slice_into_list)
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index 036eb366a2..41c8e8c854 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -117,6 +117,21 @@ new_element (enum element_type type)
   return e;
 }
 
+ELEMENT_LIST *
+new_list ()
+{
+  ELEMENT_LIST *list = (ELEMENT_LIST *) malloc (sizeof (ELEMENT_LIST));
+  memset (list, 0, sizeof (ELEMENT_LIST));
+  return list;
+}
+
+void
+destroy_list (ELEMENT_LIST * list)
+{
+  free (list->list);
+  free (list);
+}
+
 void
 destroy_associated_info (ASSOCIATED_INFO *a)
 {
diff --git a/tp/Texinfo/XS/main/tree.h b/tp/Texinfo/XS/main/tree.h
index 66efbdaba5..ea4f6710a3 100644
--- a/tp/Texinfo/XS/main/tree.h
+++ b/tp/Texinfo/XS/main/tree.h
@@ -8,6 +8,7 @@ void reset_obstacks (void);
 
 ASSOCIATED_INFO *new_associated_info (void);
 ELEMENT *new_element (enum element_type type);
+ELEMENT_LIST *new_list (void);
 void add_to_element_list (ELEMENT_LIST *list, ELEMENT *e);
 void add_to_element_contents (ELEMENT *parent, ELEMENT *e);
 void add_to_contents_as_array (ELEMENT *parent, ELEMENT *e);
@@ -33,6 +34,7 @@ ELEMENT *pop_element_from_args (ELEMENT *parent);
 ELEMENT *pop_element_from_contents (ELEMENT *parent);
 ELEMENT *contents_child_by_index (ELEMENT *e, int index);
 ELEMENT *args_child_by_index (ELEMENT *e, int index);
+void destroy_list (ELEMENT_LIST * list);
 void destroy_element (ELEMENT *e);
 void destroy_element_and_children (ELEMENT *e);
 int replace_element_in_contents (ELEMENT *parent, ELEMENT *removed,
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c 
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 2459ff8537..6829fb31f7 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -189,8 +189,7 @@ modify_tree (ELEMENT *tree,
                                            new_args, 0,
                                            new_args->number);
               i += new_args->number -1;
-              free (new_args->list);
-              free (new_args);
+              destroy_list (new_args);
             }
           else
             modify_tree (tree->args.list[i], operation, argument);
@@ -212,8 +211,7 @@ modify_tree (ELEMENT *tree,
                                               new_contents, 0,
                                               new_contents->number);
               i += new_contents->number -1;
-              free (new_contents->list);
-              free (new_contents);
+              destroy_list (new_contents);
             }
           else
             modify_tree (tree->contents.list[i], operation, argument);
@@ -236,8 +234,7 @@ modify_tree (ELEMENT *tree,
                      do it? */
                   tree->source_mark_list.list[i]->element
                       = new_element->list[0];
-                  free (new_element->list);
-                  free (new_element);
+                  destroy_list (new_element);
                 }
             }
         }
@@ -899,8 +896,7 @@ reference_to_arg_internal (const char *type,
       int *arguments_order = ref_5_args_order;
       /* container for the new elements to insert, will be destroyed
          by the caller */
-      ELEMENT_LIST *container = (ELEMENT_LIST *) malloc (sizeof 
(ELEMENT_LIST));
-      memset (container, 0, sizeof (ELEMENT_LIST));
+      ELEMENT_LIST *container = new_list ();
       ELEMENT *new = new_element (ET_NONE);
       new->parent = e->parent;
       add_to_element_list (container, new);
@@ -1109,7 +1105,7 @@ complete_node_menu (ELEMENT *node, int use_sections)
   destroy_element (node_childs);
 }
 
-ELEMENT *
+static ELEMENT *
 get_non_automatic_nodes_with_sections (ELEMENT *root)
 {
   ELEMENT *non_automatic_nodes = new_element (ET_NONE);
@@ -1310,9 +1306,7 @@ protect_text (ELEMENT *current, char *to_protect)
                                  || current->type == ET_rawline_arg)
       && strpbrk (current->text.text, to_protect))
     {
-      ELEMENT_LIST *container
-          = (ELEMENT_LIST *) malloc (sizeof (ELEMENT_LIST));
-      memset (container, 0, sizeof (ELEMENT_LIST));
+      ELEMENT_LIST *container = new_list();
       char *p = current->text.text;
       /* count UTF-8 encoded Unicode characters for source marks locations */
       size_t current_position = 0;
@@ -1520,9 +1514,7 @@ protect_hashchar_at_line_beginning_internal (const char 
*type,
                         }
                       else
                         {
-                          ELEMENT_LIST *container = (ELEMENT_LIST *)
-                            malloc (sizeof (ELEMENT_LIST));
-                          memset (container, 0, sizeof (ELEMENT_LIST));
+                          ELEMENT_LIST *container = new_list ();
                           char *current_text = strdup (current->text.text);
                           char *p = current_text;
                           int leading_spaces_nr;



reply via email to

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