ar: stop using static data
function old new delta static.ar_long_names 4 - -4 static.ar_long_name_size 4 - -4 get_header_ar 546 532 -14 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-22) Total: -22 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
58e43a4c40
commit
b74e490629
@ -34,10 +34,6 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
|||||||
char raw[60];
|
char raw[60];
|
||||||
struct ar_header formatted;
|
struct ar_header formatted;
|
||||||
} ar;
|
} ar;
|
||||||
#if ENABLE_FEATURE_AR_LONG_FILENAMES
|
|
||||||
static char *ar_long_names;
|
|
||||||
static unsigned ar_long_name_size;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* dont use xread as we want to handle the error ourself */
|
/* dont use xread as we want to handle the error ourself */
|
||||||
if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
|
if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
|
||||||
@ -81,10 +77,10 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
|||||||
* stores long filename for multiple entries, they are stored
|
* stores long filename for multiple entries, they are stored
|
||||||
* in static variable long_names for use in future entries
|
* in static variable long_names for use in future entries
|
||||||
*/
|
*/
|
||||||
ar_long_name_size = size;
|
archive_handle->ar__long_name_size = size;
|
||||||
free(ar_long_names);
|
free(archive_handle->ar__long_names);
|
||||||
ar_long_names = xzalloc(size + 1);
|
archive_handle->ar__long_names = xzalloc(size + 1);
|
||||||
xread(archive_handle->src_fd, ar_long_names, size);
|
xread(archive_handle->src_fd, archive_handle->ar__long_names, size);
|
||||||
archive_handle->offset += size;
|
archive_handle->offset += size;
|
||||||
/* Return next header */
|
/* Return next header */
|
||||||
return get_header_ar(archive_handle);
|
return get_header_ar(archive_handle);
|
||||||
@ -107,13 +103,13 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
|||||||
unsigned long_offset;
|
unsigned long_offset;
|
||||||
|
|
||||||
/* The number after the '/' indicates the offset in the ar data section
|
/* The number after the '/' indicates the offset in the ar data section
|
||||||
* (saved in ar_long_names) that contains the real filename */
|
* (saved in ar__long_names) that contains the real filename */
|
||||||
long_offset = read_num(&ar.formatted.name[1], 10,
|
long_offset = read_num(&ar.formatted.name[1], 10,
|
||||||
sizeof(ar.formatted.name) - 1);
|
sizeof(ar.formatted.name) - 1);
|
||||||
if (long_offset >= ar_long_name_size) {
|
if (long_offset >= archive_handle->ar__long_name_size) {
|
||||||
bb_error_msg_and_die("can't resolve long filename");
|
bb_error_msg_and_die("can't resolve long filename");
|
||||||
}
|
}
|
||||||
typed->name = xstrdup(ar_long_names + long_offset);
|
typed->name = xstrdup(archive_handle->ar__long_names + long_offset);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -116,6 +116,10 @@ typedef struct archive_handle_t {
|
|||||||
#if ENABLE_FEATURE_AR_CREATE
|
#if ENABLE_FEATURE_AR_CREATE
|
||||||
const char *ar__name;
|
const char *ar__name;
|
||||||
struct archive_handle_t *ar__out;
|
struct archive_handle_t *ar__out;
|
||||||
|
# if ENABLE_FEATURE_AR_LONG_FILENAMES
|
||||||
|
char *ar__long_names;
|
||||||
|
unsigned ar__long_name_size;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
} archive_handle_t;
|
} archive_handle_t;
|
||||||
/* bits in ah_flags */
|
/* bits in ah_flags */
|
||||||
|
Loading…
Reference in New Issue
Block a user