2 * Copyright (c) 2020 Red Hat GmbH. Author: Phil Sutter <phil@nwl.cc>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
13 #include "nft-chain.h"
15 struct nft_chain
*nft_chain_alloc(struct nftnl_chain
*nftnl
, bool fake
)
17 struct nft_chain
*c
= xtables_malloc(sizeof(*c
));
19 INIT_LIST_HEAD(&c
->head
);
26 void nft_chain_free(struct nft_chain
*c
)
29 nftnl_chain_free(c
->nftnl
);
33 struct nft_chain_list
*nft_chain_list_alloc(void)
35 struct nft_chain_list
*list
= xtables_malloc(sizeof(*list
));
38 INIT_LIST_HEAD(&list
->list
);
39 for (i
= 0; i
< CHAIN_NAME_HSIZE
; i
++)
40 INIT_HLIST_HEAD(&list
->names
[i
]);
45 void nft_chain_list_del(struct nft_chain
*c
)
51 void nft_chain_list_free(struct nft_chain_list
*list
)
53 struct nft_chain
*c
, *c2
;
55 list_for_each_entry_safe(c
, c2
, &list
->list
, head
) {
56 nft_chain_list_del(c
);