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

Function extend_sa_arr

dpdk/examples/ipsec-secgw/sa.c:343–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343static int
344extend_sa_arr(struct ipsec_sa **sa_tbl, uint32_t cur_cnt, uint32_t *cur_sz)
345{
346 if (*sa_tbl == NULL) {
347 *sa_tbl = calloc(SA_INIT_NB, sizeof(struct ipsec_sa));
348 if (*sa_tbl == NULL)
349 return -1;
350 *cur_sz = SA_INIT_NB;
351 return 0;
352 }
353
354 if (cur_cnt >= *cur_sz) {
355 *sa_tbl = realloc(*sa_tbl,
356 *cur_sz * sizeof(struct ipsec_sa) * 2);
357 if (*sa_tbl == NULL)
358 return -1;
359 /* clean reallocated extra space */
360 memset(&(*sa_tbl)[*cur_sz], 0,
361 *cur_sz * sizeof(struct ipsec_sa));
362 *cur_sz *= 2;
363 }
364
365 return 0;
366}
367
368void
369parse_sa_tokens(char **tokens, uint32_t n_tokens,

Callers 1

parse_sa_tokensFunction · 0.85

Calls 3

callocFunction · 0.85
memsetFunction · 0.85
reallocFunction · 0.50

Tested by

no test coverage detected