[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/call_html_perl_function.c
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/call_html_perl_function.c (get_shared_conversion_state), tp/Texinfo/XS/main/converter_types.h (HTML_SHARED_CONVERSION_STATE), tp/Texinfo/XS/convert/convert_html.c (html_finalize_output_state, html_free_converter): add key_strings STRING_LIST field in HTML_SHARED_CONVERSION_STATE to allocate and save key strings, such that they can be freed in the end. |
Date: |
Sun, 17 Dec 2023 18:06:11 -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 4fda4e520d * tp/Texinfo/XS/convert/call_html_perl_function.c
(get_shared_conversion_state), tp/Texinfo/XS/main/converter_types.h
(HTML_SHARED_CONVERSION_STATE), tp/Texinfo/XS/convert/convert_html.c
(html_finalize_output_state, html_free_converter): add key_strings STRING_LIST
field in HTML_SHARED_CONVERSION_STATE to allocate and save key strings, such
that they can be freed in the end.
4fda4e520d is described below
commit 4fda4e520d018248e8d8adcf26043f0d6c0ebd5e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Dec 18 00:06:00 2023 +0100
* tp/Texinfo/XS/convert/call_html_perl_function.c
(get_shared_conversion_state), tp/Texinfo/XS/main/converter_types.h
(HTML_SHARED_CONVERSION_STATE), tp/Texinfo/XS/convert/convert_html.c
(html_finalize_output_state, html_free_converter): add key_strings
STRING_LIST field in HTML_SHARED_CONVERSION_STATE to allocate and save
key strings, such that they can be freed in the end.
* tp/Texinfo/XS/convert/converter.c (free_generic_converter): wipe
error messages memory.
* tp/Texinfo/XS/main/convert_to_text.c (brace_no_arg_command)
(convert_to_text_internal), tp/Texinfo/XS/main/convert_utils.c
(add_heading_number), tp/Texinfo/XS/convert/convert_html.c
(html_get_tree_root_element, convert_to_html_internal): destroy tree
elements and free data to fix memory leaks detected by valgrind.
---
ChangeLog | 18 ++++++++++++++++++
tp/Texinfo/XS/convert/call_html_perl_function.c | 6 +++++-
tp/Texinfo/XS/convert/convert_html.c | 5 +++++
tp/Texinfo/XS/convert/converter.c | 3 +++
tp/Texinfo/XS/main/convert_to_text.c | 6 +++++-
tp/Texinfo/XS/main/convert_utils.c | 3 +++
tp/Texinfo/XS/main/converter_types.h | 4 ++++
7 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 19a5e0c38a..bf8009953b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-12-17 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/call_html_perl_function.c
+ (get_shared_conversion_state), tp/Texinfo/XS/main/converter_types.h
+ (HTML_SHARED_CONVERSION_STATE), tp/Texinfo/XS/convert/convert_html.c
+ (html_finalize_output_state, html_free_converter): add key_strings
+ STRING_LIST field in HTML_SHARED_CONVERSION_STATE to allocate and save
+ key strings, such that they can be freed in the end.
+
+ * tp/Texinfo/XS/convert/converter.c (free_generic_converter): wipe
+ error messages memory.
+
+ * tp/Texinfo/XS/main/convert_to_text.c (brace_no_arg_command)
+ (convert_to_text_internal), tp/Texinfo/XS/main/convert_utils.c
+ (add_heading_number), tp/Texinfo/XS/convert/convert_html.c
+ (html_get_tree_root_element, convert_to_html_internal): destroy tree
+ elements and free data to fix memory leaks detected by valgrind.
+
2023-12-17 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/utils.c (add_string): return the newly duplicated
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 12855a73f5..f3a5c183d9 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -94,14 +94,18 @@ get_shared_conversion_state (CONVERTER *self)
HE *next = hv_iternext (accessed_integers_v);
SV *selector_sv = hv_iterkeysv (next);
char *selector = (char *) SvPVutf8_nolen (selector_sv);
+ char *saved_selector;
HE *conversion_state_he = hv_fetch_ent (conversion_state_hv,
selector_sv, 0, 0);
ref_value_sv = HeVAL (conversion_state_he);
value = SvIV (SvRV (ref_value_sv));
+ saved_selector
+ = add_string (selector,
+ &self->shared_conversion_state.key_strings);
add_associated_info_integer (&self->shared_conversion_state.integers,
- selector, value);
+ saved_selector, value);
hv_delete_ent (accessed_integers_v, selector_sv, 0, 0);
}
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index b6f5c7524e..2074f1e05a 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -350,6 +350,7 @@ html_get_tree_root_element (CONVERTER *self, const ELEMENT
*command,
insertcopying, find_container);
if (cur_result->output_unit || cur_result->root)
return cur_result;
+ free (cur_result);
}
}
else if (data_cmd == CM_titlepage
@@ -9686,6 +9687,7 @@ html_finalize_output_state (CONVERTER *self)
self->associated_inline_content.number = 0;
self->shared_conversion_state.integers.info_number = 0;
+ clear_strings_list (&self->shared_conversion_state.key_strings);
html_pop_document_context (self);
@@ -9979,6 +9981,7 @@ html_free_converter (CONVERTER *self)
free_strings_list (&self->shared_conversion_state_integer);
destroy_associated_info (&self->shared_conversion_state.integers);
+ free_strings_list (&self->shared_conversion_state.key_strings);
free (self->no_arg_formatted_cmd_translated.list);
free (self->reset_target_commands.list);
@@ -10657,7 +10660,9 @@ convert_to_html_internal (CONVERTER *self, const
ELEMENT *element,
convert_to_html_internal (self, translated, &text_result,
"translated TEXT");
+
remove_element_from_list (&self->tree_to_build, translated);
+ destroy_element_and_children (translated);
}
else
{
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index e28a08b71a..a0e4d436bb 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -26,6 +26,7 @@
#include "tree.h"
#include "extra.h"
#include "utils.h"
+#include "errors.h"
#include "builtin_commands.h"
#include "node_name_normalization.h"
#include "convert_utils.h"
@@ -593,6 +594,8 @@ free_generic_converter (CONVERTER *self)
free_output_files_information (&self->output_files_information);
free_output_unit_files (&self->output_unit_files);
+
+ wipe_error_message_list (&self->error_messages);
}
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index 98369e9156..2f8e280c3b 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -240,7 +240,10 @@ brace_no_arg_command (const ELEMENT *e, TEXT_OPTIONS
*options)
{
ELEMENT *tree = translated_command_tree (options->converter, cmd);
if (tree)
- result = convert_to_text (tree, options);
+ {
+ result = convert_to_text (tree, options);
+ destroy_element_and_children (tree);
+ }
}
if (!result)
{
@@ -440,6 +443,7 @@ convert_to_text_internal (const ELEMENT *element,
TEXT_OPTIONS *text_options,
if (tree)
{
convert_to_text_internal (tree, text_options, result);
+ destroy_element_and_children (tree);
}
}
else
diff --git a/tp/Texinfo/XS/main/convert_utils.c
b/tp/Texinfo/XS/main/convert_utils.c
index 2f1491be73..6abf1c2eb1 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -216,6 +216,9 @@ add_heading_number (OPTIONS *options, const ELEMENT
*current, char *text,
if (!numbered_heading)
numbered_heading = gdt_string ("{number} {section_title}",
options, substrings, 0, 0);
+
+ destroy_named_string_element_list (substrings);
+
text_append (&result, numbered_heading);
free (numbered_heading);
}
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 3183e710e6..55557ae946 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -280,6 +280,10 @@ typedef struct HTML_SHARED_CONVERSION_STATE {
int formatted_index_entries; /* formatted_index_entries->{INDEX_ENTRY
$index_entry_ref} = 1, ++ */
int formatted_nodedescriptions; /* formatted_nodedescriptions->{ELEMENT
$node_description} = 1, ++ */
ASSOCIATED_INFO integers;
+ STRING_LIST key_strings; /* used to save the keys used in
+ ASSOCIATED_INFO integers such that they can be
+ free'd later. In general constant strings are
+ for keys, if not, key_strings should be used */
} HTML_SHARED_CONVERSION_STATE;
typedef struct MERGED_INDEX {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/call_html_perl_function.c (get_shared_conversion_state), tp/Texinfo/XS/main/converter_types.h (HTML_SHARED_CONVERSION_STATE), tp/Texinfo/XS/convert/convert_html.c (html_finalize_output_state, html_free_converter): add key_strings STRING_LIST field in HTML_SHARED_CONVERSION_STATE to allocate and save key strings, such that they can be freed in the end.,
Patrice Dumas <=