usr.bin/netstat: use roundup2 when rounding up to power of 2.
MFC after: 2 weeks
This commit is contained in:
parent
9769f6f808
commit
f6b6d216ca
@ -114,7 +114,7 @@ prepare_ifmap(size_t *pifmap_size)
|
|||||||
ifindex = sdl->sdl_index;
|
ifindex = sdl->sdl_index;
|
||||||
|
|
||||||
if (ifindex >= ifmap_size) {
|
if (ifindex >= ifmap_size) {
|
||||||
size = roundup(ifindex + 1, 32) *
|
size = roundup2(ifindex + 1, 32) *
|
||||||
sizeof(struct ifmap_entry);
|
sizeof(struct ifmap_entry);
|
||||||
if ((ifmap = realloc(ifmap, size)) == NULL)
|
if ((ifmap = realloc(ifmap, size)) == NULL)
|
||||||
errx(2, "realloc(%d) failed", size);
|
errx(2, "realloc(%d) failed", size);
|
||||||
@ -122,7 +122,7 @@ prepare_ifmap(size_t *pifmap_size)
|
|||||||
size - ifmap_size *
|
size - ifmap_size *
|
||||||
sizeof(struct ifmap_entry));
|
sizeof(struct ifmap_entry));
|
||||||
|
|
||||||
ifmap_size = roundup(ifindex + 1, 32);
|
ifmap_size = roundup2(ifindex + 1, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*ifmap[ifindex].ifname != '\0')
|
if (*ifmap[ifindex].ifname != '\0')
|
||||||
|
@ -213,7 +213,7 @@ nhop_map_update(struct nhop_map *map, uint32_t idx, char *gw, char *ifname)
|
|||||||
else
|
else
|
||||||
new_size = map->size * 2;
|
new_size = map->size * 2;
|
||||||
if (new_size <= idx)
|
if (new_size <= idx)
|
||||||
new_size = roundup(idx + 1, 32);
|
new_size = roundup2(idx + 1, 32);
|
||||||
|
|
||||||
sz = new_size * (sizeof(struct nhop_entry));
|
sz = new_size * (sizeof(struct nhop_entry));
|
||||||
if ((map->ptr = realloc(map->ptr, sz)) == NULL)
|
if ((map->ptr = realloc(map->ptr, sz)) == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user