11/*
2- * Copyright (c) 2015, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2015, 2025 , Oracle and/or its affiliates. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions
@@ -148,65 +148,6 @@ void ImageLocation::clear_data() {
148148 memset (_attributes, 0 , sizeof (_attributes));
149149}
150150
151- // ImageModuleData constructor maps out sub-tables for faster access.
152- ImageModuleData::ImageModuleData (const ImageFileReader* image_file) :
153- _image_file(image_file),
154- _endian(image_file->endian ()) {
155- }
156-
157- // Release module data resource.
158- ImageModuleData::~ImageModuleData () {
159- }
160-
161-
162- // Return the module in which a package resides. Returns NULL if not found.
163- const char * ImageModuleData::package_to_module (const char * package_name) {
164- // replace all '/' by '.'
165- char * replaced = new char [(int ) strlen (package_name) + 1 ];
166- assert (replaced != NULL && " allocation failed" );
167- int i;
168- for (i = 0 ; package_name[i] != ' \0 ' ; i++) {
169- replaced[i] = package_name[i] == ' /' ? ' .' : package_name[i];
170- }
171- replaced[i] = ' \0 ' ;
172-
173- // build path /packages/<package_name>
174- const char * radical = " /packages/" ;
175- char * path = new char [(int ) strlen (radical) + (int ) strlen (package_name) + 1 ];
176- assert (path != NULL && " allocation failed" );
177- strcpy (path, radical);
178- strcat (path, replaced);
179- delete[] replaced;
180-
181- // retrieve package location
182- ImageLocation location;
183- bool found = _image_file->find_location (path, location);
184- delete[] path;
185- if (!found) {
186- return NULL ;
187- }
188-
189- // retrieve offsets to module name
190- int size = (int )location.get_attribute (ImageLocation::ATTRIBUTE_UNCOMPRESSED);
191- u1* content = new u1[size];
192- assert (content != NULL && " allocation failed" );
193- _image_file->get_resource (location, content);
194- u1* ptr = content;
195- // sequence of sizeof(8) isEmpty|offset. Use the first module that is not empty.
196- u4 offset = 0 ;
197- for (i = 0 ; i < size; i+=8 ) {
198- u4 isEmpty = _endian->get (*((u4*)ptr));
199- ptr += 4 ;
200- if (!isEmpty) {
201- offset = _endian->get (*((u4*)ptr));
202- break ;
203- }
204- ptr += 4 ;
205- }
206- delete[] content;
207- return _image_file->get_strings ().get (offset);
208- }
209-
210151// Manage a table of open image files. This table allows multiple access points
211152// to share an open image.
212153ImageFileReaderTable::ImageFileReaderTable () : _count(0 ), _max(_growth) {
@@ -340,8 +281,7 @@ ImageFileReader* ImageFileReader::id_to_reader(u8 id) {
340281}
341282
342283// Constructor initializes to a closed state.
343- ImageFileReader::ImageFileReader (const char * name, bool big_endian) :
344- _module_data(NULL ) {
284+ ImageFileReader::ImageFileReader (const char * name, bool big_endian) {
345285 // Copy the image file name.
346286 int len = (int ) strlen (name) + 1 ;
347287 _name = new char [len];
@@ -362,10 +302,6 @@ ImageFileReader::~ImageFileReader() {
362302 delete[] _name;
363303 _name = NULL ;
364304 }
365-
366- if (_module_data != NULL ) {
367- delete _module_data;
368- }
369305}
370306
371307// Open image file for read access.
@@ -414,11 +350,7 @@ bool ImageFileReader::open() {
414350 _location_bytes = _index_data + location_bytes_offset;
415351 // Compute address of index string table.
416352 _string_bytes = _index_data + string_bytes_offset;
417-
418- // Initialize the module data
419- _module_data = new ImageModuleData (this );
420- // Successful open (if memory allocation succeeded).
421- return _module_data != NULL ;
353+ return true ;
422354}
423355
424356// Close image file.
@@ -433,11 +365,6 @@ void ImageFileReader::close() {
433365 osSupport::close (_fd);
434366 _fd = -1 ;
435367 }
436-
437- if (_module_data != NULL ) {
438- delete _module_data;
439- _module_data = NULL ;
440- }
441368}
442369
443370// Read directly from the file.
@@ -567,8 +494,3 @@ void ImageFileReader::get_resource(ImageLocation& location, u1* uncompressed_dat
567494 assert (is_read && " error reading from image or short read" );
568495 }
569496}
570-
571- // Return the ImageModuleData for this image
572- ImageModuleData * ImageFileReader::get_image_module_data () {
573- return _module_data;
574- }
0 commit comments