diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-06 12:53:17 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-06 12:53:17 +0300 |
commit | aa4977d8e549d9fff2b2946f03d304e435eb20f1 (patch) | |
tree | bc7c7fe4ab64263a9f8356762cb8f7e77165de73 /archival/libunarchive/get_header_cpio.c | |
parent | 86350f8d5f5d5a1006cffe0bedccd625f012702f (diff) |
libunarchive: clean up dirty hacks. code shrank as a result
function old new delta
cpio_main 526 539 +13
init_handle 57 58 +1
init_archive_deb_ar 34 35 +1
get_header_ar 408 409 +1
dpkg_main 3900 3901 +1
unpack_package 516 515 -1
rpm_main 1673 1672 -1
tar_main 774 767 -7
get_header_cpio 990 972 -18
data_extract_all 750 727 -23
get_header_tar 1631 1576 -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/6 up/down: 17/-105) Total: -88 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/libunarchive/get_header_cpio.c')
-rw-r--r-- | archival/libunarchive/get_header_cpio.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/archival/libunarchive/get_header_cpio.c b/archival/libunarchive/get_header_cpio.c index 52854dff9..ddc49f70e 100644 --- a/archival/libunarchive/get_header_cpio.c +++ b/archival/libunarchive/get_header_cpio.c @@ -25,15 +25,6 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) int major, minor, nlink, mode, inode; unsigned size, uid, gid, mtime; -#define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0])) -#define created_hardlinks (*(hardlinks_t **)(&archive_handle->ah_priv[1])) -#define block_count (archive_handle->ah_priv[2]) -// if (!archive_handle->ah_priv_inited) { -// archive_handle->ah_priv_inited = 1; -// hardlinks_to_create = NULL; -// created_hardlinks = NULL; -// } - /* There can be padding before archive header */ data_align(archive_handle, 4); @@ -86,7 +77,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) if (strcmp(file_header->name, "TRAILER!!!") == 0) { /* Always round up. ">> 9" divides by 512 */ - block_count = (void*)(ptrdiff_t) ((archive_handle->offset + 511) >> 9); + archive_handle->cpio__blocks = (uoff_t)(archive_handle->offset + 511) >> 9; goto create_hardlinks; } @@ -112,13 +103,13 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) strcpy(new->name, file_header->name); /* Put file on a linked list for later */ if (size == 0) { - new->next = hardlinks_to_create; - hardlinks_to_create = new; + new->next = archive_handle->cpio__hardlinks_to_create; + archive_handle->cpio__hardlinks_to_create = new; return EXIT_SUCCESS; /* Skip this one */ /* TODO: this breaks cpio -t (it does not show hardlinks) */ } - new->next = created_hardlinks; - created_hardlinks = new; + new->next = archive_handle->cpio__created_hardlinks; + archive_handle->cpio__created_hardlinks = new; } file_header->device = makedev(major, minor); @@ -142,11 +133,11 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) free(file_header->link_target); free(file_header->name); - while (hardlinks_to_create) { + while (archive_handle->cpio__hardlinks_to_create) { hardlinks_t *cur; - hardlinks_t *make_me = hardlinks_to_create; + hardlinks_t *make_me = archive_handle->cpio__hardlinks_to_create; - hardlinks_to_create = make_me->next; + archive_handle->cpio__hardlinks_to_create = make_me->next; memset(file_header, 0, sizeof(*file_header)); file_header->mtime = make_me->mtime; @@ -158,7 +149,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) /*file_header->link_target = NULL;*/ /* Try to find a file we are hardlinked to */ - cur = created_hardlinks; + cur = archive_handle->cpio__created_hardlinks; while (cur) { /* TODO: must match maj/min too! */ if (cur->inode == make_me->inode) { @@ -176,14 +167,14 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle) if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) archive_handle->action_data(archive_handle); /* Move to the list of created hardlinked files */ - make_me->next = created_hardlinks; - created_hardlinks = make_me; + make_me->next = archive_handle->cpio__created_hardlinks; + archive_handle->cpio__created_hardlinks = make_me; next_link: ; } - while (created_hardlinks) { - hardlinks_t *p = created_hardlinks; - created_hardlinks = p->next; + while (archive_handle->cpio__created_hardlinks) { + hardlinks_t *p = archive_handle->cpio__created_hardlinks; + archive_handle->cpio__created_hardlinks = p->next; free(p); } |