From af433e8a902f3291c7a5532709236258c3a26a74 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Fri, 11 Jun 2021 17:14:40 +0200 Subject: [PATCH] findWorkArea --- src/scheduler.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index 301228d..a0f5e43 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -23,6 +23,7 @@ #include "../include/localworker.h" #include +#include static void *GreatScheduler(void *parameters); @@ -98,19 +99,21 @@ static void *GreatScheduler(void *params) // -------------------------------------------------------------------------- // // Scheduler thread main function // // -------------------------------------------------------------------------- // -static Center_t *findWorkArea(Center_t *centerList, long ruleRadius) +static Center_t *findWorkArea(Center_t *centerList, int ruleRadius) { - Center_t *myCenter = 10; /* Je suis né quelque part.(ou pas !).*/ + Center_t *myCenter = (Center_t*) malloc(sizeof(Center_t)); + centerAssign(myCenter, 10, 0, 0); /* Je suis né quelque part.(ou pas !).*/ - int i; - for (i = 0; i < centerList.size() - 1; i ++){ - if (myCenter - centerList[i] < ruleRadius){ - printLog("FAIL: no work area available at %p\n", myCenter); + while (centerList != NULL){ + if (abs(myCenter->x - centerList->x) < ruleRadius){ + printLog("FAIL: no work area available at %d\n", myCenter->x); + free(myCenter); return NULL; } + centerList = centerList->next; } - printLog("SUCCESS ! at %p: < I've find a center.\n", myCenter); + printLog("SUCCESS ! at %d: < I've find a center.\n", myCenter->x); return myCenter; }