Debian Codegraph @

src/str_array.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-or-later */cxx . . $ `<file>/src/str_array.c`/
2 /*
3 * (C) 2024 Red Hat GmbH
4 * Author: Phil Sutter <[email protected]>
5 */
6 #include <libmnl/libmnl.h>
7 #include <linux/netfilter/nf_tables.h>cxx . . $ `<file>/include/linux/netfilter/nf_tables.h`/
8
9 #include "str_array.h"cxx . . $ `<file>/include/str_array.h`/
10 #include "utils.h"cxx . . $ `<file>/include/utils.h`/
11
12 void nftnl_str_array_clearcxx . . $ nftnl_str_array_clear(da9ec48ca4ecf134).(struct nftnl_str_arraycxx . . $ nftnl_str_array# *sa)
13 {
14 while (sa->lencxx . . $ nftnl_str_array#len. > 0)
15 freecxx . . $ free(5d22bdacc48458e8).(sa->arraycxx . . $ nftnl_str_array#array.[--sa->lencxx . . $ nftnl_str_array#len.]);
16 freecxx . . $ free(5d22bdacc48458e8).(sa->arraycxx . . $ nftnl_str_array#array.);
17 }
18
19 int nftnl_str_array_setcxx . . $ nftnl_str_array_set(c729e707ba698544).(struct nftnl_str_arraycxx . . $ nftnl_str_array# *sa, const char * const *array)
20 {
21 int len = 0;
22
23 while (array[len])
24 len++;
25
26 nftnl_str_array_clearcxx . . $ nftnl_str_array_clear(da9ec48ca4ecf134).(sa);
27 sa->arraycxx . . $ nftnl_str_array#array. = calloccxx . . $ calloc(63a7bf2941bfcd7a).(len + 1, sizeof(char *));
28 if (!sa->arraycxx . . $ nftnl_str_array#array.)
29 return -1;
30
31 while (sa->lencxx . . $ nftnl_str_array#len. < len) {
32 sa->arraycxx . . $ nftnl_str_array#array.[sa->lencxx . . $ nftnl_str_array#len.] = strdupcxx . . $ strdup(a8b8e32347182212).(array[sa->lencxx . . $ nftnl_str_array#len.]);
33 if (!sa->arraycxx . . $ nftnl_str_array#array.[sa->lencxx . . $ nftnl_str_array#len.]) {
34 nftnl_str_array_clearcxx . . $ nftnl_str_array_clear(da9ec48ca4ecf134).(sa);
35 return -1;
36 }
37 sa->lencxx . . $ nftnl_str_array#len.++;
38 }
39 return 0;
40 }
41
42 int nftnl_parse_devscxx . . $ nftnl_parse_devs(2b1f6624489517c0).(struct nftnl_str_arraycxx . . $ nftnl_str_array# *sa, const struct nlattrcxx . . $ nlattr# *nest)
43 {
44 struct nlattrcxx . . $ nlattr# *attr;
45 int len = 0;
46
47 mnl_attr_for_each_nestedcxx . . $ `<external>/12386019527593959648/libmnl.h:152:9`!(attr, nest) {
48 switch(mnl_attr_get_typecxx . . $ mnl_attr_get_type(1da47bcc4c4b975).(attr)) {
49 default:
50 return -1;
51 case NFTA_DEVICE_NAMEcxx . . $ NFTA_DEVICE_NAME.:
52 case NFTA_DEVICE_PREFIXcxx . . $ NFTA_DEVICE_PREFIX.:
53 len++;
54 }
55 }
56
57 nftnl_str_array_clearcxx . . $ nftnl_str_array_clear(da9ec48ca4ecf134).(sa);
58 sa->arraycxx . . $ nftnl_str_array#array. = calloccxx . . $ calloc(63a7bf2941bfcd7a).(len + 1, sizeof(char *));
59 if (!sa->arraycxx . . $ nftnl_str_array#array.)
60 return -1;
61
62 mnl_attr_for_each_nestedcxx . . $ `<external>/12386019527593959648/libmnl.h:152:9`!(attr, nest) {
63 sa->arraycxx . . $ nftnl_str_array#array.[sa->lencxx . . $ nftnl_str_array#len.] = nftnl_attr_get_ifnamecxx . . $ nftnl_attr_get_ifname(5e785b67b24f52d1).(attr);
64 if (!sa->arraycxx . . $ nftnl_str_array#array.[sa->lencxx . . $ nftnl_str_array#len.]) {
65 nftnl_str_array_clearcxx . . $ nftnl_str_array_clear(da9ec48ca4ecf134).(sa);
66 return -1;
67 }
68 sa->lencxx . . $ nftnl_str_array#len.++;
69 }
70 return 0;
71 }