| 106 | static uint32_t sp_in_sz; |
| 107 | |
| 108 | static int |
| 109 | extend_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 | |
| 134 | void |
no test coverage detected