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

Function table_alloc

dpdk/app/test-pmd/config.c:1653–1694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1651}
1652
1653static int
1654table_alloc(uint32_t id, struct port_table **table,
1655 struct port_table **list)
1656{
1657 struct port_table *lst = *list;
1658 struct port_table **ppt;
1659 struct port_table *pt = NULL;
1660
1661 *table = NULL;
1662 if (id == UINT32_MAX) {
1663 /* taking first available ID */
1664 if (lst) {
1665 if (lst->id == UINT32_MAX - 1) {
1666 printf("Highest table ID is already"
1667 " assigned, delete it first\n");
1668 return -ENOMEM;
1669 }
1670 id = lst->id + 1;
1671 } else {
1672 id = 0;
1673 }
1674 }
1675 pt = calloc(1, sizeof(*pt));
1676 if (!pt) {
1677 printf("Allocation of table failed\n");
1678 return -ENOMEM;
1679 }
1680 ppt = list;
1681 while (*ppt && (*ppt)->id > id)
1682 ppt = &(*ppt)->next;
1683 if (*ppt && (*ppt)->id == id) {
1684 printf("Table #%u is already assigned,"
1685 " delete it first\n", id);
1686 free(pt);
1687 return -EINVAL;
1688 }
1689 pt->next = *ppt;
1690 pt->id = id;
1691 *ppt = pt;
1692 *table = pt;
1693 return 0;
1694}
1695
1696/** Get info about flow management resources. */
1697int

Callers 1

Calls 3

callocFunction · 0.85
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected