From b950d80c24b69c97e8bfc01c4657b2546cc9b3bc Mon Sep 17 00:00:00 2001 From: bakere1 <bakere1@student.unimelb.edu.au> Date: Tue, 30 Mar 2021 09:51:41 +1100 Subject: [PATCH] Fixed strtok warning, and added PIDLEN. --- allocate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/allocate.c b/allocate.c index f71b3c2..6ad9bb7 100644 --- a/allocate.c +++ b/allocate.c @@ -10,11 +10,12 @@ #include "llist.h" #define INT_MAX __INT_MAX__ +#define PIDLEN 16 typedef struct { int timeArrived; int timeCompleted; //instant of time completed - char processID[16]; + char processID[PIDLEN]; int executionTime; char parallelisable; int timeRemaining; @@ -396,6 +397,7 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll process *headProcess; process *paralizedProcess; char * parentPid; + char Pid[PIDLEN]; headProcess = headData(processQueue); @@ -407,7 +409,8 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll headProcess->timeRemaining = 0; if (headProcess->parallelisable == 'p') { //printf("process had finished, and was a paralized subprocess\n"); - parentPid = strtok(headProcess->processID, "."); + strncpy(Pid, headProcess->processID, PIDLEN); + parentPid = strtok(Pid, "."); paralizedProcess = parallelParent(paralellProcesses, parentPid); paralizedProcess->subProcsRunning -= 1; if (paralizedProcess->subProcsRunning == 0) { -- GitLab