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

Function if_grow

freebsd/net/if.c:559–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557#endif
558
559static void *
560if_grow(void)
561{
562 int oldlim;
563 u_int n;
564 struct ifnet **e;
565 void *old;
566
567 old = NULL;
568 IFNET_WLOCK_ASSERT();
569 oldlim = V_if_indexlim;
570 IFNET_WUNLOCK();
571 n = (oldlim << 1) * sizeof(*e);
572 e = malloc(n, M_IFNET, M_WAITOK | M_ZERO);
573 IFNET_WLOCK();
574 if (V_if_indexlim != oldlim) {
575 free(e, M_IFNET);
576 return (NULL);
577 }
578 if (V_ifindex_table != NULL) {
579 memcpy((caddr_t)e, (caddr_t)V_ifindex_table, n/2);
580 old = V_ifindex_table;
581 }
582 V_if_indexlim <<= 1;
583 V_ifindex_table = e;
584 return (old);
585}
586
587/*
588 * Allocate a struct ifnet and an index for an interface. A layer 2

Callers 2

ifindex_allocFunction · 0.85
vnet_if_initFunction · 0.85

Calls 3

mallocFunction · 0.85
freeFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected