Commit b927d3a4 by Mark Wielaard Committed by Mark Wielaard

parse.y (process_imports): Allocate (and free) original_name only when not already defined.

       * parse.y (process_imports): Allocate (and free) original_name only
       when not already defined.
       * jcf-parse.c (read_class): Free results of find_class() and
       lrealpath().
       (java_parse_file): Keep pointer to head of file_list and free when
       done. Free result of lrealpath().

From-SVN: r93109
parent e1a5510b
2005-01-08 Mark Wielaard <mark@klomp.org>
* parse.y (process_imports): Allocate (and free) original_name only
when not already defined.
* jcf-parse.c (read_class): Free results of find_class() and
lrealpath().
(java_parse_file): Keep pointer to head of file_list and free when
done. Free result of lrealpath().
2005-01-05 Tom Tromey <tromey@redhat.com> 2005-01-05 Tom Tromey <tromey@redhat.com>
* gcj.texi (Standard Properties): java.ext.dirs is now used. * gcj.texi (Standard Properties): java.ext.dirs is now used.
......
...@@ -530,11 +530,17 @@ read_class (tree name) ...@@ -530,11 +530,17 @@ read_class (tree name)
if (jcf == NULL) if (jcf == NULL)
{ {
const char* path_name;
this_jcf.zipd = NULL; this_jcf.zipd = NULL;
jcf = &this_jcf; jcf = &this_jcf;
if (find_class (IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name),
&this_jcf, 1) == 0) path_name = find_class (IDENTIFIER_POINTER (name),
IDENTIFIER_LENGTH (name),
&this_jcf, 1);
if (path_name == 0)
return 0; return 0;
else
free((char *) path_name);
} }
current_jcf = jcf; current_jcf = jcf;
...@@ -542,6 +548,7 @@ read_class (tree name) ...@@ -542,6 +548,7 @@ read_class (tree name)
if (current_jcf->java_source) if (current_jcf->java_source)
{ {
const char *filename = current_jcf->filename; const char *filename = current_jcf->filename;
char *real_path;
tree given_file, real_file; tree given_file, real_file;
FILE *finput; FILE *finput;
int generate; int generate;
...@@ -551,7 +558,9 @@ read_class (tree name) ...@@ -551,7 +558,9 @@ read_class (tree name)
given_file = get_identifier (filename); given_file = get_identifier (filename);
filename = IDENTIFIER_POINTER (given_file); filename = IDENTIFIER_POINTER (given_file);
real_file = get_identifier (lrealpath (filename)); real_path = lrealpath (filename);
real_file = get_identifier (real_path);
free (real_path);
generate = IS_A_COMMAND_LINE_FILENAME_P (given_file); generate = IS_A_COMMAND_LINE_FILENAME_P (given_file);
output_class = current_class = NULL_TREE; output_class = current_class = NULL_TREE;
...@@ -1025,7 +1034,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -1025,7 +1034,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
{ {
int filename_count = 0; int filename_count = 0;
location_t save_location = input_location; location_t save_location = input_location;
char *list, *next; char *file_list = NULL, *list, *next;
tree node; tree node;
FILE *finput = NULL; FILE *finput = NULL;
int in_quotes = 0; int in_quotes = 0;
...@@ -1063,6 +1072,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -1063,6 +1072,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
} }
fclose (finput); fclose (finput);
finput = NULL; finput = NULL;
file_list = list;
} }
else else
list = (char *) main_input_filename; list = (char *) main_input_filename;
...@@ -1138,6 +1148,9 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -1138,6 +1148,9 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
list = next; list = next;
} }
if (file_list != NULL)
free (file_list);
if (filename_count == 0) if (filename_count == 0)
warning ("no input file specified"); warning ("no input file specified");
...@@ -1159,13 +1172,16 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -1159,13 +1172,16 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
for (node = current_file_list; node; node = TREE_CHAIN (node)) for (node = current_file_list; node; node = TREE_CHAIN (node))
{ {
unsigned char magic_string[4]; unsigned char magic_string[4];
char *real_path;
uint32 magic = 0; uint32 magic = 0;
tree name = DECL_NAME (node); tree name = DECL_NAME (node);
tree real_file; tree real_file;
const char *filename = IDENTIFIER_POINTER (name); const char *filename = IDENTIFIER_POINTER (name);
/* Skip already parsed files */ /* Skip already parsed files */
real_file = get_identifier (lrealpath (filename)); real_path = lrealpath (filename);
real_file = get_identifier (real_path);
free (real_path);
if (HAS_BEEN_ALREADY_PARSED_P (real_file)) if (HAS_BEEN_ALREADY_PARSED_P (real_file))
continue; continue;
......
...@@ -6955,14 +6955,14 @@ process_imports (void) ...@@ -6955,14 +6955,14 @@ process_imports (void)
tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import)); tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
char *original_name; char *original_name;
original_name = xmemdup (IDENTIFIER_POINTER (to_be_found),
IDENTIFIER_LENGTH (to_be_found),
IDENTIFIER_LENGTH (to_be_found) + 1);
/* Don't load twice something already defined. */ /* Don't load twice something already defined. */
if (IDENTIFIER_CLASS_VALUE (to_be_found)) if (IDENTIFIER_CLASS_VALUE (to_be_found))
continue; continue;
original_name = xmemdup (IDENTIFIER_POINTER (to_be_found),
IDENTIFIER_LENGTH (to_be_found),
IDENTIFIER_LENGTH (to_be_found) + 1);
while (1) while (1)
{ {
tree left; tree left;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment