diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cycle_detection.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/src/cycle_detection.c b/src/cycle_detection.c index 6f6c9af..4bbf62b 100644 --- a/src/cycle_detection.c +++ b/src/cycle_detection.c @@ -3,29 +3,21 @@ #include "linked_list.h" #include "vector.h" #include <stdio.h> -#include <stdlib.h> #include <stdint.h> void cycle_detection(Graph *g) { int n = g->num_vertices; - int *indegree = calloc(n, sizeof(int)); - if (!indegree) { - fprintf(stderr, "Memory allocation failed: could not create list.\n"); - free(indegree); - return; - } + int indegree[n]; LinkedList *queue = linked_list_new(); if (!queue) { fprintf(stderr, "Memory allocation failed: could not create queue.\n"); - free(indegree); return; } Vector *list = vector_new(); if (!list) { fprintf(stderr, "Memory allocation failed: could not create vector.\n"); - free(indegree); linked_list_delete(queue); return; } @@ -74,5 +66,4 @@ void cycle_detection(Graph *g) { linked_list_delete(queue); vector_delete(list); - free(indegree); } |