| 341 | } |
| 342 | |
| 343 | static int |
| 344 | extend_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 | |
| 368 | void |
| 369 | parse_sa_tokens(char **tokens, uint32_t n_tokens, |
no test coverage detected