| 92 | } |
| 93 | |
| 94 | static int |
| 95 | graph_node_add(struct graph *graph, struct node *node) |
| 96 | { |
| 97 | struct graph_node *graph_node; |
| 98 | size_t sz; |
| 99 | |
| 100 | /* Skip the duplicate nodes */ |
| 101 | STAILQ_FOREACH(graph_node, &graph->node_list, next) |
| 102 | if (strncmp(node->name, graph_node->node->name, |
| 103 | RTE_NODE_NAMESIZE) == 0) |
| 104 | return 0; |
| 105 | |
| 106 | /* Allocate new graph node object */ |
| 107 | sz = sizeof(*graph_node) + node->nb_edges * sizeof(struct node *); |
| 108 | graph_node = calloc(1, sz); |
| 109 | |
| 110 | if (graph_node == NULL) |
| 111 | SET_ERR_JMP(ENOMEM, free, "Failed to calloc %s object", |
| 112 | node->name); |
| 113 | |
| 114 | /* Initialize the graph node */ |
| 115 | graph_node->node = node; |
| 116 | |
| 117 | /* Add to graph node list */ |
| 118 | STAILQ_INSERT_TAIL(&graph->node_list, graph_node, next); |
| 119 | return 0; |
| 120 | |
| 121 | free: |
| 122 | free(graph_node); |
| 123 | return -rte_errno; |
| 124 | } |
| 125 | |
| 126 | static struct graph_node * |
| 127 | node_to_graph_node(struct graph *graph, struct node *node) |
no test coverage detected