[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8100] parsetexi avoid memory leaks
From: |
gavinsmith0123 |
Subject: |
[8100] parsetexi avoid memory leaks |
Date: |
Fri, 17 Aug 2018 06:06:54 -0400 (EDT) |
Revision: 8100
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8100
Author: gavin
Date: 2018-08-17 06:06:53 -0400 (Fri, 17 Aug 2018)
Log Message:
-----------
parsetexi avoid memory leaks
Modified Paths:
--------------
trunk/tp/Texinfo/XS/parsetexi/api.c
trunk/tp/Texinfo/XS/parsetexi/indices.c
trunk/tp/Texinfo/XS/parsetexi/indices.h
trunk/tp/Texinfo/XS/parsetexi/input.c
Modified: trunk/tp/Texinfo/XS/parsetexi/api.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/api.c 2018-08-17 09:14:14 UTC (rev 8099)
+++ trunk/tp/Texinfo/XS/parsetexi/api.c 2018-08-17 10:06:53 UTC (rev 8100)
@@ -49,6 +49,7 @@
wipe_user_commands ();
wipe_values ();
wipe_macros ();
+ wipe_indices ();
init_index_commands ();
wipe_errors ();
reset_context_stack ();
Modified: trunk/tp/Texinfo/XS/parsetexi/indices.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/indices.c 2018-08-17 09:14:14 UTC (rev
8099)
+++ trunk/tp/Texinfo/XS/parsetexi/indices.c 2018-08-17 10:06:53 UTC (rev
8100)
@@ -20,9 +20,9 @@
#include "parser.h"
#include "indices.h"
-INDEX **index_names;
-int number_of_indices;
-int space_for_indices;
+INDEX **index_names = 0;
+int number_of_indices = 0;
+int space_for_indices = 0;
typedef struct {
enum command_id cmd;
@@ -126,7 +126,31 @@
free (cmdname);
}
+static void
+wipe_index (INDEX *idx)
+{
+ int i;
+ for (i = 0; i < idx->index_number; i++)
+ {
+ ; /* all data is referenced elsewhere */
+ }
+ free (idx->index_entries);
+}
+
void
+wipe_indices (void)
+{
+ int i;
+ for (i = 0; i < number_of_indices; i++)
+ {
+ wipe_index (index_names[i]);
+ free (index_names[i]);
+ }
+ number_of_indices = 0;
+ return;
+}
+
+void
init_index_commands (void)
{
INDEX *idx;
Modified: trunk/tp/Texinfo/XS/parsetexi/indices.h
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/indices.h 2018-08-17 09:14:14 UTC (rev
8099)
+++ trunk/tp/Texinfo/XS/parsetexi/indices.h 2018-08-17 10:06:53 UTC (rev
8100)
@@ -7,3 +7,4 @@
enum command_id index_at_command, ELEMENT *current,
ELEMENT *content);
INDEX *ultimate_index (INDEX *index);
+void wipe_indices (void);
Modified: trunk/tp/Texinfo/XS/parsetexi/input.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/input.c 2018-08-17 09:14:14 UTC (rev
8099)
+++ trunk/tp/Texinfo/XS/parsetexi/input.c 2018-08-17 10:06:53 UTC (rev
8100)
@@ -466,14 +466,13 @@
{
int i;
input_number = 0;
- return;
for (i = 0; i < input_number; i++)
{
switch (input_stack[i].type)
{
case IN_file:
- fclose (input_stack[i].file);
- free (input_stack[i].text);
+ if (input_stack[i].file != stdin)
+ fclose (input_stack[i].file);
break;
case IN_text:
free (input_stack[i].text);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8100] parsetexi avoid memory leaks,
gavinsmith0123 <=