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

Function cluster_add

dpdk/lib/graph/graph_stats.c:267–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267static int
268cluster_add(struct cluster *cluster, struct graph *graph)
269{
270 rte_graph_t count;
271 size_t sz;
272
273 /* Skip the if graph is already added to cluster */
274 for (count = 0; count < cluster->nb_graphs; count++)
275 if (cluster->graphs[count] == graph)
276 return 0;
277
278 /* Expand the cluster if required to store graph objects */
279 if (cluster->nb_graphs + 1 > cluster->size) {
280 cluster->size = RTE_MAX(1, cluster->size * 2);
281 sz = sizeof(struct graph *) * cluster->size;
282 cluster->graphs = realloc(cluster->graphs, sz);
283 if (cluster->graphs == NULL)
284 SET_ERR_JMP(ENOMEM, free, "Failed to realloc");
285 }
286
287 /* Add graph to cluster */
288 cluster->graphs[cluster->nb_graphs++] = graph;
289 return 0;
290
291free:
292 return -rte_errno;
293}
294
295static void
296cluster_fini(struct cluster *cluster)

Callers 1

Calls 1

reallocFunction · 0.50

Tested by

no test coverage detected