diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-01 13:23:36 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-01 13:23:36 +0200 |
commit | 8aea2d1dc437b5b497170ef9c1b6854aee8f5dcf (patch) | |
tree | 0999ed4664c74cf90896d8b11f7f4a9dc06e8d48 /lib/tar/cleanup.c | |
parent | f0d18050d832498c8e230c04084675455fef391f (diff) |
cleanup: split tar code up, remove some duplications
This commit attempts to split some of the monolitic tar parsing code up
into multiple functions in seperate files. Also, some code duplication
(like reading a record into memory which was implemented twice) is
removed.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/tar/cleanup.c')
-rw-r--r-- | lib/tar/cleanup.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/tar/cleanup.c b/lib/tar/cleanup.c new file mode 100644 index 0000000..c4d1734 --- /dev/null +++ b/lib/tar/cleanup.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +#include "internal.h" + +void free_sparse_list(sparse_map_t *sparse) +{ + sparse_map_t *old; + + while (sparse != NULL) { + old = sparse; + sparse = sparse->next; + free(old); + } +} + +void clear_header(tar_header_decoded_t *hdr) +{ + free_sparse_list(hdr->sparse); + free(hdr->name); + free(hdr->link_target); + memset(hdr, 0, sizeof(*hdr)); +} |