From 641cf50bc04bd4eb48513999c848edfb8676a74a Mon Sep 17 00:00:00 2001 From: Bohdan Kapliuk Date: Sun, 3 Nov 2024 17:15:59 +0200 Subject: [PATCH] cv6 --- cv6/a_station.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index c6cb67d..23cba38 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -26,13 +26,15 @@ void destroy_station(struct station* station){ } } -int select_track(struct station* station, const char* target){ +int select_track(struct station* station, const char* target) { unsigned long hash = 5381; int c; - while (c = *target++) - hash = ((hash << 5) + hash) + c; - return hash; + while ((c = *target++)) { + hash = ((hash << 5) + hash) + c; + } + + return hash % station->track_count; } void add_target_capacity(struct station* station,const char* target, int capacity){