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

Function graph_node_add

dpdk/lib/graph/graph.c:94–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94static int
95graph_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
121free:
122 free(graph_node);
123 return -rte_errno;
124}
125
126static struct graph_node *
127node_to_graph_node(struct graph *graph, struct node *node)

Callers 3

graph_node_edges_addFunction · 0.85
expand_pattern_to_nodeFunction · 0.85
graph_cloneFunction · 0.85

Calls 3

strncmpFunction · 0.85
callocFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected