MCPcopy Create free account
hub / github.com/F-Stack/f-stack / extend_sp_arr

Function extend_sp_arr

dpdk/examples/ipsec-secgw/sp4.c:108–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106static uint32_t sp_in_sz;
107
108static int
109extend_sp_arr(struct acl4_rules **sp_tbl, uint32_t cur_cnt, uint32_t *cur_sz)
110{
111 if (*sp_tbl == NULL) {
112 *sp_tbl = calloc(INIT_ACL_RULE_NUM, sizeof(struct acl4_rules));
113 if (*sp_tbl == NULL)
114 return -1;
115 *cur_sz = INIT_ACL_RULE_NUM;
116 return 0;
117 }
118
119 if (cur_cnt >= *cur_sz) {
120 *sp_tbl = realloc(*sp_tbl,
121 *cur_sz * sizeof(struct acl4_rules) * 2);
122 if (*sp_tbl == NULL)
123 return -1;
124 /* clean reallocated extra space */
125 memset(&(*sp_tbl)[*cur_sz], 0,
126 *cur_sz * sizeof(struct acl4_rules));
127 *cur_sz *= 2;
128 }
129
130 return 0;
131}
132
133
134void

Callers 1

parse_sp4_tokensFunction · 0.70

Calls 3

callocFunction · 0.85
memsetFunction · 0.85
reallocFunction · 0.50

Tested by

no test coverage detected