| 206 | } |
| 207 | |
| 208 | void |
| 209 | nhop_map_update(struct nhop_map *map, uint32_t idx, char *gw, char *ifname) |
| 210 | { |
| 211 | if (idx >= map->size) { |
| 212 | uint32_t new_size; |
| 213 | size_t sz; |
| 214 | if (map->size == 0) |
| 215 | new_size = 32; |
| 216 | else |
| 217 | new_size = map->size * 2; |
| 218 | if (new_size <= idx) |
| 219 | new_size = roundup(idx + 1, 32); |
| 220 | |
| 221 | sz = new_size * (sizeof(struct nhop_entry)); |
| 222 | if ((map->ptr = realloc(map->ptr, sz)) == NULL) |
| 223 | errx(2, "realloc(%zu) failed", sz); |
| 224 | |
| 225 | memset(&map->ptr[map->size], 0, (new_size - map->size) * sizeof(struct nhop_entry)); |
| 226 | map->size = new_size; |
| 227 | } |
| 228 | |
| 229 | strlcpy(map->ptr[idx].ifname, ifname, sizeof(map->ptr[idx].ifname)); |
| 230 | strlcpy(map->ptr[idx].gw, gw, sizeof(map->ptr[idx].gw)); |
| 231 | } |
| 232 | |
| 233 | #ifndef FSTACK |
| 234 | static struct nhop_entry * |
no test coverage detected