From dec98d4d0b1ac7fb10c63ae88954cc7f82828b3d Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Wed, 13 Oct 2021 09:44:00 +0200 Subject: [PATCH 1/5] Changed legal notice to reflect reality --- AUTHORS | 37 ------------------------------------- Makefile | 3 ++- debian/control | 2 +- debian/copyright | 2 +- include/arrows.h | 3 ++- include/base.h | 3 ++- include/centers.h | 3 ++- include/cmds.h | 3 ++- include/model.h | 3 ++- include/parsing.h | 3 ++- include/scheduler.h | 3 ++- include/server.h | 3 ++- include/supervisor.h | 3 ++- include/terminal.h | 3 ++- include/worker.h | 3 ++- include/xml.h | 3 ++- src/arrows.c | 3 ++- src/centers.c | 3 ++- src/cli.c | 3 ++- src/cmds.c | 3 ++- src/main.c | 3 ++- src/model.c | 3 ++- src/parsing.c | 3 ++- src/scheduler.c | 3 ++- src/server.c | 3 ++- src/supervisor.c | 3 ++- src/tests/arrows.c | 3 ++- src/tests/centers.c | 3 ++- src/tests/localworker.c | 3 ++- src/tests/scheduler.c | 3 ++- src/tests/server.c | 3 ++- src/worker.c | 3 ++- 32 files changed, 60 insertions(+), 68 deletions(-) delete mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 3caedb3..0000000 --- a/AUTHORS +++ /dev/null @@ -1,37 +0,0 @@ -#=----------------------------------------------------------------------------=# -# Project authors file # -# # -# Copyright © 2021 The Gem-graph Project # -# # -# This file is part of gem-graph. # -# # -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see . # -#=----------------------------------------------------------------------------=# - -The gem-graph development team (named in the sources The Gem-graph Project) is -composed of all core contributors of the project. Its representatives are the -owners of the gem-graph project repository, and own the copyright in it. - - Founders and owner of the gem-graph project repository - - Jean Sirmai (jean) - Adrien Bourmault (neox) - - Main contributors - - Jean Sirmai (jean) - Adrien Bourmault (neox) - - - Contact : - diff --git a/Makefile b/Makefile index 0a1f301..93765a8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ #=----------------------------------------------------------------------------=# # Makefile # # # -# Copyright © 2021 The Gem-graph Project # +# Copyright © 2021 Libre en Communs (contact@a-lec.org) # +# Copyright © 2021 Adrien Bourmault (neox@a-lec.org) # # # # This file is part of gem-graph. # # # diff --git a/debian/control b/debian/control index eef2923..8341870 100644 --- a/debian/control +++ b/debian/control @@ -6,5 +6,5 @@ Depends: libxml2 Architecture: amd64 Essential: no Installed-Size: 112760 -Maintainer: The Gem-graph Project +Maintainer: Libre en Communs (contact@a-lec.org) Description: The wonderful gem-graph computation server diff --git a/debian/copyright b/debian/copyright index f73fe76..60bafbd 100644 --- a/debian/copyright +++ b/debian/copyright @@ -2,7 +2,7 @@ This is a packacked upstream version of gem-graph-server The sources may be found at . -Copyright © 2021 The Gem-graph Project +Copyright © 2021 Libre en Communs (contact@a-lec.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as diff --git a/include/arrows.h b/include/arrows.h index 8543726..f4ea9b1 100644 --- a/include/arrows.h +++ b/include/arrows.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Local workers definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/base.h b/include/base.h index 14881e2..c348dcf 100644 --- a/include/base.h +++ b/include/base.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // base definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/centers.h b/include/centers.h index f1007e1..be2c188 100644 --- a/include/centers.h +++ b/include/centers.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Local workers definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/cmds.h b/include/cmds.h index 720c583..705f42b 100644 --- a/include/cmds.h +++ b/include/cmds.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Server supported commands definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/model.h b/include/model.h index 9e1666d..845b657 100644 --- a/include/model.h +++ b/include/model.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Model definitions // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/parsing.h b/include/parsing.h index 9952b9a..128a1f9 100644 --- a/include/parsing.h +++ b/include/parsing.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // XML parsing module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/scheduler.h b/include/scheduler.h index eeec788..83e1a95 100644 --- a/include/scheduler.h +++ b/include/scheduler.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Scheduler definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/server.h b/include/server.h index f03d624..203938d 100644 --- a/include/server.h +++ b/include/server.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Server definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/supervisor.h b/include/supervisor.h index 5932f1b..6605c87 100644 --- a/include/supervisor.h +++ b/include/supervisor.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Supervisor definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/terminal.h b/include/terminal.h index 1a5107e..436e6b1 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Terminal management tools // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/worker.h b/include/worker.h index b00f18b..c80a144 100644 --- a/include/worker.h +++ b/include/worker.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Local workers definition // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/include/xml.h b/include/xml.h index d56d876..4809a57 100644 --- a/include/xml.h +++ b/include/xml.h @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // XML management tools // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/arrows.c b/src/arrows.c index b808069..7634932 100644 --- a/src/arrows.c +++ b/src/arrows.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Arrows management module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/centers.c b/src/centers.c index 0984b87..2eba517 100644 --- a/src/centers.c +++ b/src/centers.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Centers management module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/cli.c b/src/cli.c index 1631b3d..7b40808 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Command line interface main file // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/cmds.c b/src/cmds.c index 9de3fd4..4940869 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Server management module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/main.c b/src/main.c index a7e9667..052c66a 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Main // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/model.c b/src/model.c index a89af1a..77a89e8 100644 --- a/src/model.c +++ b/src/model.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Model management module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/parsing.c b/src/parsing.c index f625df8..822f9d3 100644 --- a/src/parsing.c +++ b/src/parsing.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // XML parsing module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/scheduler.c b/src/scheduler.c index 82a9268..7bfde69 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Scheduler module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/server.c b/src/server.c index 4ee5352..ff738a8 100644 --- a/src/server.c +++ b/src/server.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Server management module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/supervisor.c b/src/supervisor.c index 9849f8b..03cf758 100644 --- a/src/supervisor.c +++ b/src/supervisor.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Supervisor module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/tests/arrows.c b/src/tests/arrows.c index 4756857..60c915a 100644 --- a/src/tests/arrows.c +++ b/src/tests/arrows.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Arrows tests // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/tests/centers.c b/src/tests/centers.c index 3796519..d416006 100644 --- a/src/tests/centers.c +++ b/src/tests/centers.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Centers tests // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/tests/localworker.c b/src/tests/localworker.c index 3b87380..a8d7d3a 100644 --- a/src/tests/localworker.c +++ b/src/tests/localworker.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Local worker tests // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/tests/scheduler.c b/src/tests/scheduler.c index 6764c2b..141b386 100644 --- a/src/tests/scheduler.c +++ b/src/tests/scheduler.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Scheduler tests // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/tests/server.c b/src/tests/server.c index 80f92af..76f36d3 100644 --- a/src/tests/server.c +++ b/src/tests/server.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Server tests // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // diff --git a/src/worker.c b/src/worker.c index a943360..bbe934c 100644 --- a/src/worker.c +++ b/src/worker.c @@ -1,7 +1,8 @@ //=-------------------------------------------------------------------------=// // Local worker module // // // -// Copyright © 2021 The Gem-graph Project // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2021 Adrien Bourmault (neox@a-lec.org) // // // // This file is part of gem-graph. // // // From 1c0967863515e22915aa2b202a168835a6e9d1fd Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 14 Oct 2021 08:34:19 +0200 Subject: [PATCH 2/5] Some cleanup --- Makefile | 2 -- src/main.c | 17 +++++++---------- src/model.c | 19 ++++++++++--------- src/parsing.c | 2 +- src/scheduler.c | 6 +++--- src/tests/centers.c | 41 ++++++++++++++++++---------------------- src/tests/test_realloc.c | 2 +- 7 files changed, 40 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index 93765a8..1d5cc68 100644 --- a/Makefile +++ b/Makefile @@ -137,5 +137,3 @@ run-cli: all @bin/gem-graph-ctl run-tests: tests @bin/tests/scheduler - -include $(DEPS) diff --git a/src/main.c b/src/main.c index 052c66a..42ded6c 100644 --- a/src/main.c +++ b/src/main.c @@ -28,7 +28,7 @@ static Server_t *server; -static void SigIntTermHandler(int signum) +static void sigtermHandler(int signum) { server->pleaseStop = true; printLog("Server stopping\n"); @@ -37,9 +37,6 @@ static void SigIntTermHandler(int signum) printLog("All model shutted down\n"); } -// TODO parse args to discover : -// - config files directory -// - models & users directories int main(int argc, char **argv) { int options; @@ -51,17 +48,17 @@ int main(int argc, char **argv) switch (options) { case 'C': printLog("Config : %s\n", optarg); - parameters.configDir = (char*) calloc(1, strlen(optarg) + 1); + parameters.configDir = calloc(1, strlen(optarg) + 1); strcpy(parameters.configDir, optarg); break; case 'M': printLog("Models : %s\n", optarg); - parameters.modelDir = (char*) calloc(1, strlen(optarg) + 1); + parameters.modelDir = calloc(1, strlen(optarg) + 1); strcpy(parameters.modelDir, optarg); break; case 'U': printLog("Users : %s\n", optarg); - parameters.userDir = (char*) calloc(1, strlen(optarg) + 1); + parameters.userDir = calloc(1, strlen(optarg) + 1); strcpy(parameters.userDir, optarg); break; case ':': @@ -112,14 +109,14 @@ int main(int argc, char **argv) printLog("Starting gem-graph-server...\n"); // Register new interrupt handler - signal(SIGINT, SigIntTermHandler); - signal(SIGTERM, SigIntTermHandler); + signal(SIGINT, sigtermHandler); + signal(SIGTERM, sigtermHandler); // Initializing random generator t = time(&t); srand((unsigned) t); - server = (Server_t*) calloc(1, sizeof(Server_t)); + server = calloc(1, sizeof(*server)); // Initializing model system ModelSystemInit(¶meters); diff --git a/src/model.c b/src/model.c index 77a89e8..db08dbd 100644 --- a/src/model.c +++ b/src/model.c @@ -67,7 +67,8 @@ int ModelLoad(int id) // Creating structure for the Scheduler - knownModel[id-1]->scheduler = (Scheduler_t*) calloc(1, sizeof(Scheduler_t)); + knownModel[id-1]->scheduler = + calloc(1, sizeof(*knownModel[id-1]->scheduler)); loadedModelSize++; @@ -165,9 +166,9 @@ void ModelAddToKnown(Model_t **newModel) knownModelSize++; // create socket knownModel = - (Model_t**) realloc(knownModel, knownModelSize * sizeof(Model_t*)); + (Model_t**) realloc(knownModel, knownModelSize * sizeof(*knownModel)); // populate socket - knownModel[knownModelSize-1] = (Model_t*) calloc(1, sizeof(Model_t)); + knownModel[knownModelSize-1] = calloc(1, sizeof(**knownModel)); // populate model knownModel[knownModelSize-1]->id = knownModelSize; // return value @@ -177,16 +178,16 @@ void ModelAddToKnown(Model_t **newModel) // continue. model population knownModel[knownModelSize-1]->name = - (char *) calloc(1, sizeof(char) * MODEL_STRING_SIZE); + calloc(1, sizeof(char) * MODEL_STRING_SIZE); knownModel[knownModelSize-1]->filename = - (char *) calloc(1, sizeof(char) * MODEL_STRING_SIZE); + calloc(1, sizeof(char) * MODEL_STRING_SIZE); knownModel[knownModelSize-1]->owner = - (char *) calloc(1, sizeof(char) * MODEL_STRING_SIZE); + calloc(1, sizeof(char) * MODEL_STRING_SIZE); knownModel[knownModelSize-1]->version = - (char *) calloc(1, sizeof(char) * MODEL_STRING_SIZE); + calloc(1, sizeof(char) * MODEL_STRING_SIZE); knownModel[knownModelSize-1]->space_xMax = XMAX; knownModel[knownModelSize-1]->space_yMax = YMAX; @@ -233,9 +234,9 @@ void ModelSystemInit(Parameters_t *parameters) Model_t *newModel; char *extensionPosition; - loadedModel = (Model_t**) calloc(1, sizeof(Model_t*)); + loadedModel = calloc(1, sizeof(*loadedModel)); - knownModel = (Model_t**) calloc(1, sizeof(Model_t*)); + knownModel = calloc(1, sizeof(*knownModel)); knownModelSize = 0; loadedModelSize = 0; diff --git a/src/parsing.c b/src/parsing.c index 822f9d3..53f846e 100644 --- a/src/parsing.c +++ b/src/parsing.c @@ -353,7 +353,7 @@ int ParseModelIdentityXML(Model_t *model, Parameters_t *params) }; // Allocating space for schema file path - schemPath = (char*) calloc(1, strlen(params->modelDir) + schemPath = calloc(1, strlen(params->modelDir) + strlen("/schemas/model_ .xmls")); printLog("Preparsing model %s\n", model->name); diff --git a/src/scheduler.c b/src/scheduler.c index 7bfde69..00dddb4 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -52,7 +52,7 @@ static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow, register Center_t *currentCenter, *newCenter; currentCenter = centersList->next; - newCenter = (Center_t*) malloc(sizeof(Center_t)); + newCenter = malloc(sizeof(Center_t)); while (currentCenter){ if ( (xmax && (abs(electedArrow->x - currentCenter->x) <= ruleRadius)) @@ -101,9 +101,9 @@ static void *schedulerMain(void *scheduler) printLog("%d threads available.\n", ncpu); // Data structures - workerArray = (Worker_t*) calloc(ncpu, sizeof(Worker_t)); + workerArray = calloc(ncpu, sizeof(*workerArray)); nworker = 0; - centersList = (Center_t*) calloc(1, sizeof(Center_t)); + centersList = calloc(1, sizeof(*centersList)); // Initiate the arrowArray lock if (err = ArrowsInitLock(args->arrowArray), err != 0) { diff --git a/src/tests/centers.c b/src/tests/centers.c index d416006..b11344b 100644 --- a/src/tests/centers.c +++ b/src/tests/centers.c @@ -46,14 +46,14 @@ bool TestCenterRemove Center_t *anyCenter = NULL; // adding a something to a bad pointer - centerRemove(anyCenter); + CenterRemove(anyCenter); //printf("* Status of centers list after deleting NULL\n"); //printCenters(anyCenter); assert(anyCenter == NULL); - anyCenter = (Center_t*) calloc(1, sizeof(Center_t)); + anyCenter = calloc(1, sizeof(*anyCenter)); //printf("* Initial status of centers list\n"); //printCenters(anyCenter); @@ -63,25 +63,20 @@ bool TestCenterRemove assert(anyCenter != NULL); // Deleting a lonely pointer - centerRemove(anyCenter); + CenterRemove(anyCenter); //printf("* Status of centers list after deleting a lonely center\n"); //printCenters(anyCenter); - anyCenter = (Center_t*) calloc(1, sizeof(Center_t)); - centerAdd(anyCenter, (Center_t*) calloc(1, sizeof(Center_t))); - centerAdd(anyCenter, (Center_t*) calloc(1, sizeof(Center_t))); - centerAdd(anyCenter, (Center_t*) calloc(1, sizeof(Center_t))); - centerAdd(anyCenter, (Center_t*) calloc(1, sizeof(Center_t))); - centerAdd(anyCenter, (Center_t*) calloc(1, sizeof(Center_t))); + anyCenter = calloc(1, sizeof(*anyCenter)); Center_t *oldfirst = anyCenter->next; Center_t *oldsecond = anyCenter->next->next; // Deleting a the first pointer - centerRemove(anyCenter->next); + CenterRemove(anyCenter->next); //printf("* Status of centers list after deleting the head center\n"); //printCenters(anyCenter); @@ -96,14 +91,14 @@ bool TestCenterAdd(void) Center_t *anyCenter = NULL; // adding a something to a bad pointer - centerAdd(anyCenter, NULL); + CenterAdd(anyCenter, NULL); //printf("* Status of centers list after adding something to NULL\n"); //printCenters(anyCenter); assert(anyCenter == NULL); - anyCenter = (Center_t*) calloc(1, sizeof(Center_t)); + anyCenter = calloc(1, sizeof(Center_t)); //printf("* Initial status of centers list\n"); //printCenters(anyCenter); @@ -113,7 +108,7 @@ bool TestCenterAdd(void) assert(anyCenter != NULL); // adding a bad pointer - centerAdd(anyCenter, NULL); + CenterAdd(anyCenter, NULL); //printf("* Status of centers list after adding NULL\n"); //printCenters(anyCenter); @@ -123,8 +118,8 @@ bool TestCenterAdd(void) assert(anyCenter != NULL); // adding a good pointer - Center_t *goodpointer = (Center_t*) calloc(1, sizeof(Center_t)); - centerAdd(anyCenter, goodpointer); + Center_t *goodpointer = calloc(1, sizeof(Center_t)); + CenterAdd(anyCenter, goodpointer); //printf("* Status of centers list after adding a center\n"); //printCenters(anyCenter); @@ -136,8 +131,8 @@ bool TestCenterAdd(void) assert(goodpointer->next == NULL); // adding another good pointer - Center_t *newgoodpointer = (Center_t*) calloc(1, sizeof(Center_t)); - centerAdd(anyCenter, newgoodpointer); + Center_t *newgoodpointer = calloc(1, sizeof(Center_t)); + CenterAdd(anyCenter, newgoodpointer); //printf("* Status of centers list after adding another center\n"); //printCenters(anyCenter); @@ -149,10 +144,10 @@ bool TestCenterAdd(void) assert(newgoodpointer->next == goodpointer); // adding another good pointer - Center_t *strangepointer = (Center_t*) calloc(1, sizeof(Center_t)); + Center_t *strangepointer = calloc(1, sizeof(Center_t)); strangepointer->next = (Center_t*)0xCAFEBABE; strangepointer->prev = (Center_t*)0xCAFEBABE; - centerAdd(anyCenter, strangepointer); + CenterAdd(anyCenter, strangepointer); //printf("* Status of centers list after adding a strange center\n"); //printCenters(anyCenter); @@ -170,13 +165,13 @@ bool TestCenterAdd(void) int main(int argc, char **argv) { - printf("\n==== Testing centers.c/centerAdd() ====\n"); + printf("\n==== Testing centers.c/CenterAdd() ====\n"); TestCenterAdd(); - printf("\n==== Testing centers.c/centerAdd() ==== : OK\n"); + printf("\n==== Testing centers.c/CenterAdd() ==== : OK\n"); - printf("\n==== Testing centers.c/centerRemove() ====\n"); + printf("\n==== Testing centers.c/CenterRemove() ====\n"); TestCenterRemove(); - printf("\n==== Testing centers.c/centerRemove() ==== : OK\n"); + printf("\n==== Testing centers.c/CenterRemove() ==== : OK\n"); return 0; } diff --git a/src/tests/test_realloc.c b/src/tests/test_realloc.c index 1ddeab6..6a28911 100644 --- a/src/tests/test_realloc.c +++ b/src/tests/test_realloc.c @@ -3,7 +3,7 @@ int main(void) { - int *a = (int*) malloc(7 * sizeof(int)); + int *a = malloc(7 * sizeof(int)); printf("Salut! Tableau d'entiers à l'adresse %p\n", a); From f9187c3b283082362df1630cf9639d32e5618465 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 14 Oct 2021 09:11:12 +0200 Subject: [PATCH 3/5] Cleanup --- src/worker.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/worker.c b/src/worker.c index bbe934c..1207015 100644 --- a/src/worker.c +++ b/src/worker.c @@ -52,38 +52,7 @@ static void *WorkerMain(void *worker) int size = args->globalDrawingSpace->size; - /* In each cell: the West (left) site is 0, the East (right) site is 1 */ - for (int orig=0; orig < size; orig++){ - int nxt1 = (orig + 1) % size, - nxt2 = (orig + 2) % size, - prv1 = (orig - 1 + size) % size; - - if( - args->globalDrawingSpace->space[orig].sites[1].nArrow == 1 - && args->globalDrawingSpace->space[nxt2].sites[0].nArrow == 0 - - ) { - args->globalDrawingSpace->space[orig].sites[1].nArrow = 0; - args->globalDrawingSpace->space[nxt1].sites[0].nArrow = 0; - args->globalDrawingSpace->space[nxt1].sites[1].nArrow = 1; - args->globalDrawingSpace->space[nxt2].sites[0].nArrow = 1; - - /* TODO args->arrowArray->array[1].siteId = 0;*/ - } - - else if( - args->globalDrawingSpace->space[orig].sites[1].nArrow == 1 - && args->globalDrawingSpace->space[prv1].sites[0].nArrow == 0 - - ) { - args->globalDrawingSpace->space[orig].sites[1].nArrow = 0; - args->globalDrawingSpace->space[nxt1].sites[0].nArrow = 0; - args->globalDrawingSpace->space[orig].sites[0].nArrow = 1; - args->globalDrawingSpace->space[prv1].sites[1].nArrow = 1; - - /* TODO args->arrowArray->array[1].siteId = 0;*/ - } - } + // TODO execute rule comparison args->returnValue = a; args->terminated = true; From 0cc24b8a653d84813909f0456c757169f46cae1a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 14 Oct 2021 09:11:38 +0200 Subject: [PATCH 4/5] Cleanup --- src/worker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/worker.c b/src/worker.c index 1207015..19d9b5c 100644 --- a/src/worker.c +++ b/src/worker.c @@ -29,7 +29,7 @@ static void *WorkerMain(void *worker); /* -------------------------------------------------------------------------- */ // -------------------------------------------------------------------------- // -// Scheduler init function // +// Worker init function // // -------------------------------------------------------------------------- // void WorkerInit(Worker_t *worker) { @@ -40,7 +40,7 @@ void WorkerInit(Worker_t *worker) } // -------------------------------------------------------------------------- // -// Scheduler thread main function // +// Worker thread main function // // -------------------------------------------------------------------------- // static void *WorkerMain(void *worker) { From 6db8075c9bb0198896e0ffe16669aca5e439e40a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 14 Oct 2021 11:27:48 +0200 Subject: [PATCH 5/5] Cleanup --- include/arrows.h | 6 ++++++ src/parsing.c | 25 +++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/arrows.h b/include/arrows.h index f4ea9b1..ef887ff 100644 --- a/include/arrows.h +++ b/include/arrows.h @@ -51,3 +51,9 @@ static inline int ArrowsReleaseLock(ArrowArray_t *arrowArray) { return pthread_spin_unlock(&arrowArray->lock); } + +Arrow_t *ArrowAdd(Scheduler_t *scheduler, int x, int y, int z, int siteId, + int weight); + +bool ArrowRemove(Scheduler_t *scheduler, int x, int y, int z, int siteId, + int weight); diff --git a/src/parsing.c b/src/parsing.c index 53f846e..35839cb 100644 --- a/src/parsing.c +++ b/src/parsing.c @@ -21,6 +21,7 @@ //=-------------------------------------------------------------------------=// #include "../include/parsing.h" +#include "../include/arrows.h" #include "../include/model.h" // -------------------------------------------------------------------------- // @@ -72,11 +73,14 @@ int parseArrowFieldXML (xmlDocPtr doc, int currentParser, xmlNodePtr currentNode) { - xmlChar *x, *y, *z; + Model_t *destination = ModelTable->table[currentParser].destination; + xmlChar *x, *y, *z, *siteId, *weight; x = xmlGetProp(currentNode, (xmlChar*)"x"); y = xmlGetProp(currentNode, (xmlChar*)"y"); z = xmlGetProp(currentNode, (xmlChar*)"z"); + siteId = xmlGetProp(currentNode, (xmlChar*)"siteId"); + weight = xmlGetProp(currentNode, (xmlChar*)"weight"); // Detect children if (currentNode->xmlChildrenNode) { @@ -94,7 +98,18 @@ int parseArrowFieldXML (xmlDocPtr doc, return -1; } - // TODO create arrow in model + // Create arrow in model + if (destination->scheduler) { + ArrowAdd(destination->scheduler, + atoi((char*)x), atoi((char*)y), atoi((char*)z), + atoi((char*)siteId), atoi((char*)weight)); + } else { + xmlFree(x); + xmlFree(y); + xmlFree(z); + + return -1; + } xmlFree(x); xmlFree(y); @@ -103,9 +118,6 @@ int parseArrowFieldXML (xmlDocPtr doc, return 0; } -// -------------------------------------------------------------------------- // -// Parsing an arrow (but yeah that prints) // -// -------------------------------------------------------------------------- // int parseSpaceSizeFieldXML (xmlDocPtr doc, ModelParserTableXML_t *ModelTable, int currentParser, @@ -340,7 +352,8 @@ int ParseModelIdentityXML(Model_t *model, Parameters_t *params) {(const xmlChar *)"space_param", parseParentFieldXML, model}, {(const xmlChar *)"dimension", parseStubFieldXML, model}, {(const xmlChar *)"size", parseSpaceSizeFieldXML, model}, - {(const xmlChar *)"site_multiplicity", parseStubFieldXML, model}, + {(const xmlChar *)"site_multiplicity", parseIntFieldXML, + &model->siteNumber}, // TODO lacking implementation (model side) {(const xmlChar *)"boundaries", parseStubFieldXML, model},