Use a generic llist_t to store the names of hardlinked files. function old new delta cpio_o 1140 1122 -18
Signed-off-by: Ron Yorston <[email protected]> --- archival/cpio.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/archival/cpio.c b/archival/cpio.c index 7149782d7..836609fc3 100644 --- a/archival/cpio.c +++ b/archival/cpio.c @@ -223,13 +223,9 @@ static off_t cpio_pad4(off_t size) * It's ok to exit instead of return. */ static NOINLINE int cpio_o(void) { - struct name_s { - struct name_s *next; - char name[1]; - }; struct inodes_s { struct inodes_s *next; - struct name_s *names; + llist_t *names; struct stat st; #if ENABLE_FEATURE_CPIO_RENUMBER_INODES ino_t mapped_inode; @@ -277,7 +273,6 @@ static NOINLINE int cpio_o(void) /* Store hardlinks for later processing, dont output them */ if (!S_ISDIR(st.st_mode) && st.st_nlink > 1) { - struct name_s *n; struct inodes_s *l; /* Do we have this hardlink remembered? */ @@ -302,11 +297,7 @@ static NOINLINE int cpio_o(void) l = l->next; } /* Add new name to "l->names" list */ - n = xmalloc(sizeof(*n) + strlen(name)); - strcpy(n->name, name); - n->next = l->names; - l->names = n; - + llist_add_to(&l->names, xstrdup(name)); free(line); continue; } @@ -320,8 +311,7 @@ static NOINLINE int cpio_o(void) if (links) { /* Output hardlink's data */ st = links->st; - name = links->names->name; - links->names = links->names->next; + name = llist_pop(&links->names); #if ENABLE_FEATURE_CPIO_RENUMBER_INODES if (links->mapped_inode) st.st_ino = links->mapped_inode; @@ -332,7 +322,7 @@ static NOINLINE int cpio_o(void) links = links->next; else st.st_size = 0; - /* NB: we leak links->names and/or links, + /* NB: we leak links->names->name and/or links, * this is intended (we exit soon anyway) */ } else { /* If no (more) hardlinks to output, -- 2.34.1 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
