| 265 | } |
| 266 | |
| 267 | static int |
| 268 | cluster_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 | |
| 291 | free: |
| 292 | return -rte_errno; |
| 293 | } |
| 294 | |
| 295 | static void |
| 296 | cluster_fini(struct cluster *cluster) |
no test coverage detected