From a868ec89e8272c0cdf27e062785c4b5c6dcf66c5 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Sat, 14 Jul 2001 08:49:53 +0000 Subject: Allow the unarchive() extract_list variable to be NULL, meaning extract all --- ar.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ar.c') diff --git a/ar.c b/ar.c index 2a764ff..7f3396c 100644 --- a/ar.c +++ b/ar.c @@ -70,17 +70,17 @@ extern int ar_main(int argc, char **argv) /* check ar magic */ fread(ar_magic, 1, 8, src_stream); + archive_offset = 8; if (strncmp(ar_magic,"!",7) != 0) { error_msg_and_die("invalid magic"); } - archive_offset = 8; - extract_names = malloc(sizeof(char *)); - extract_names[0] = NULL; + /* Create a list of files to extract */ while (optind < argc) { + extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2)); + extract_names[num_of_entries] = xstrdup(argv[optind]); num_of_entries++; - *extract_names = realloc(*extract_names, num_of_entries); - extract_names[num_of_entries - 1] = xstrdup(argv[optind]); + extract_names[num_of_entries] = NULL; optind++; } -- cgit v1.1