aboutsummaryrefslogtreecommitdiff
path: root/lib/tar/src/cleanup.c
blob: 145f34d65ce77be295d1ffa5eb1af8604eb102ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
 * cleanup.c
 *
 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
 */
#include "config.h"

#include "internal.h"
#include "sqfs/xattr.h"
#include <stdlib.h>
#include <string.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)
{
	sqfs_xattr_list_free(hdr->xattr);
	free_sparse_list(hdr->sparse);
	free(hdr->name);
	free(hdr->link_target);
	memset(hdr, 0, sizeof(*hdr));
}