From 7bf031d67114adf7783ae3f0728132046556c7f0 Mon Sep 17 00:00:00 2001 From: Anton Dolozin Date: Tue, 4 Nov 2025 23:04:31 +0100 Subject: [PATCH] Plugged memory error --- du5/a_station.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/du5/a_station.c b/du5/a_station.c index 2796913..1b400cc 100644 --- a/du5/a_station.c +++ b/du5/a_station.c @@ -41,11 +41,16 @@ void add_target_capacity(struct station* station,const char* target, int capacit } if(count < res){ - struct car* next = (struct car*)calloc(10, sizeof(struct car)); + struct car* next = (struct car*)calloc(1, sizeof(struct car)); strcpy(next->value, target); next->capacity = capacity; + if(ptr){ ptr->next = next; - return; + return;} + else{ + *station->tracks = next; + return; + } } ptr->capacity += capacity;