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

Function edge_update

dpdk/lib/graph/node.c:212–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212static rte_edge_t
213edge_update(struct node *node, struct node *prev, rte_edge_t from,
214 const char **next_nodes, rte_edge_t nb_edges)
215{
216 rte_edge_t i, max_edges, count = 0;
217 struct node *new_node;
218 bool need_realloc;
219 size_t sz;
220
221 if (from == RTE_EDGE_ID_INVALID)
222 from = node->nb_edges;
223
224 /* Don't create hole in next_nodes[] list */
225 if (from > node->nb_edges) {
226 rte_errno = ENOMEM;
227 goto fail;
228 }
229
230 /* Remove me from list */
231 STAILQ_REMOVE(&node_list, node, node, next);
232
233 /* Allocate the storage space for new node if required */
234 max_edges = from + nb_edges;
235 need_realloc = max_edges > node->nb_edges;
236 if (need_realloc) {
237 sz = sizeof(struct node) + (max_edges * RTE_NODE_NAMESIZE);
238 new_node = realloc(node, sz);
239 if (new_node == NULL) {
240 rte_errno = ENOMEM;
241 goto restore;
242 } else {
243 node = new_node;
244 }
245 }
246
247 /* Update the new nodes name */
248 for (i = from; i < max_edges; i++, count++) {
249 if (rte_strscpy(node->next_nodes[i], next_nodes[count],
250 RTE_NODE_NAMESIZE) < 0)
251 goto restore;
252 }
253restore:
254 /* Update the linked list to point new node address in prev node */
255 if (prev)
256 STAILQ_INSERT_AFTER(&node_list, prev, node, next);
257 else
258 STAILQ_INSERT_HEAD(&node_list, node, next);
259
260 if (need_realloc)
261 node->nb_edges = max_edges;
262
263fail:
264 return count;
265}
266
267rte_edge_t
268rte_node_edge_shrink(rte_node_t id, rte_edge_t size)

Callers 1

rte_node_edge_updateFunction · 0.85

Calls 2

rte_strscpyFunction · 0.85
reallocFunction · 0.50

Tested by

no test coverage detected