texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 4 Oct 2024 06:31:34 -0400 (EDT)

branch: master
commit 2c9d0958e635fcca153d89d8ef96621bd87a5ff5
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Aug 12 12:06:07 2024 +0200

    * tp/Texinfo/XS/main/tree.c (reallocate_list_for)
    (insert_list_slice_into_list): use size_t for added elements number.
    
    * tp/Texinfo/XS/main/tree.c (remove_slice_from_contents): use size_t
    for indices.
---
 ChangeLog                 |  8 ++++++++
 tp/Texinfo/XS/main/tree.c | 12 +++++++++---
 tp/Texinfo/XS/main/tree.h |  2 +-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b32c813fb8..3ab1f0746a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-08-12  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/tree.c (reallocate_list_for)
+       (insert_list_slice_into_list): use size_t for added elements number.
+
+       * tp/Texinfo/XS/main/tree.c (remove_slice_from_contents): use size_t
+       for indices.
+
 2024-08-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 1a7acb4acc..1760bc90c1 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -350,7 +350,7 @@ reallocate_const_element_list (CONST_ELEMENT_LIST *list)
 
 /* Make sure there is space for at least N more elements. */
 static void
-reallocate_list_for (int n, ELEMENT_LIST *list)
+reallocate_list_for (size_t n, ELEMENT_LIST *list)
 {
   if (list->number + n >= list->space)
     {
@@ -372,6 +372,9 @@ add_to_const_element_list (CONST_ELEMENT_LIST *list, const 
ELEMENT *e)
 void
 add_to_element_list (ELEMENT_LIST *list, ELEMENT *e)
 {
+  /* NOTE there could be theoretically an overflow if
+     list->number + 1 > max (size_t).  The numbers are big, this is unlikely
+     to happen */
   reallocate_list (list);
 
   list->list[list->number++] = e;
@@ -441,7 +444,10 @@ void
 insert_list_slice_into_list (ELEMENT_LIST *to, size_t where,
                              const ELEMENT_LIST *from, size_t start, size_t 
end)
 {
-  int num = end - start;
+  /* NOTE there could be theoretically an overflow if
+     list->number + num > max (size_t).  The numbers are big, this is unlikely
+     to happen */
+  size_t num = end - start;
   reallocate_list_for (num, to);
 
   memmove (&to->list[where + num],
@@ -584,7 +590,7 @@ add_element_if_not_in_list (ELEMENT_LIST *list, ELEMENT *e)
 /* Remove elements from START inclusive to END exclusive.  Do not
    free any of them. */
 void
-remove_slice_from_contents (ELEMENT *parent, int start, int end)
+remove_slice_from_contents (ELEMENT *parent, size_t start, size_t end)
 {
   memmove (&parent->e.c->contents.list[start],
            &parent->e.c->contents.list[end],
diff --git a/tp/Texinfo/XS/main/tree.h b/tp/Texinfo/XS/main/tree.h
index cf6963becd..c5bad2a885 100644
--- a/tp/Texinfo/XS/main/tree.h
+++ b/tp/Texinfo/XS/main/tree.h
@@ -40,7 +40,7 @@ const ELEMENT *remove_from_const_element_list 
(CONST_ELEMENT_LIST *list,
                                                size_t where);
 ELEMENT *remove_from_contents (ELEMENT *parent, size_t where);
 ELEMENT *remove_from_args (ELEMENT *parent, size_t where);
-void remove_slice_from_contents (ELEMENT *parent, int start, int end);
+void remove_slice_from_contents (ELEMENT *parent, size_t start, size_t end);
 ELEMENT *last_args_child (const ELEMENT *current);
 ELEMENT *last_contents_child (const ELEMENT *current);
 ELEMENT *pop_element_from_args (ELEMENT *parent);



reply via email to

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