WIP: memory leaks fsm/measures/tools fsm_tools_list_test() < OK
The function fsm_tools_list_test() calls: - fsm_tools_list_insert() - fsm_tools_list_view() - fsm_tools_list_pop() - fsm_tools_list_clear() The status: SUMMARY: AddressSanitizer: 9488 byte(s) leaked in 340 allocation(s). is unchanged before/after introduction of the files: - fsm/measures/tools.c - fsm/measures/data.c and the execution of the function fsm_tools_list_test()
This commit is contained in:
parent
f7279883ec
commit
80b15346a5
7 changed files with 305 additions and 1 deletions
6
Makefile
6
Makefile
|
@ -1,4 +1,4 @@
|
|||
.PHONY: run clean install all docs man
|
||||
.PHONY: run clean install all docs man my # A phony target is not a file name
|
||||
.DELETE_ON_ERROR: $(BINDIR)/Getting_Started_with_GTK
|
||||
.DEFAULT_GOAL: all
|
||||
|
||||
|
@ -14,6 +14,10 @@ WARNINGS = -Wall
|
|||
DEBUG = -ggdb -fno-omit-frame-pointer \
|
||||
-fdiagnostics-color=always \
|
||||
-fsanitize=address,undefined -fstack-protector-strong
|
||||
# -fsanitize=leak # << même sortie console que: -fsanitize=address
|
||||
# -fsanitize=address -fstack-protector-strong
|
||||
# -fsanitize=memory
|
||||
# -fuse-ld=gold
|
||||
OPTIMIZE = -O3
|
||||
|
||||
BINDIR=bin
|
||||
|
|
7
docs/icons ressources
Normal file
7
docs/icons ressources
Normal file
|
@ -0,0 +1,7 @@
|
|||
https://tabler.io/icons <<
|
||||
|
||||
design minimaliste
|
||||
licence MIT
|
||||
format SVG
|
||||
|
||||
Jonathan Sahm CTO - Software architect
|
|
@ -251,3 +251,15 @@ void fsm_relay_close_log();
|
|||
|
||||
void fsm_init();
|
||||
void fsm_close();
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** phantom documentation */
|
||||
typedef struct fsm_struct_list_tool {
|
||||
int value; /**< *value phantom documentation */
|
||||
struct fsm_struct_list_tool *suiv; /**< *suiv phantom documentation */
|
||||
} fsm_struct_list_tool ;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -80,6 +80,9 @@
|
|||
*/
|
||||
static void fsm_structures_init()
|
||||
{
|
||||
|
||||
fsm_tools_list_test();
|
||||
|
||||
/**< will be introduced later on:
|
||||
|
||||
fsm_add_log (info, FSM, "fsm/dispatch", "measures list init()",
|
||||
|
|
66
src/fsm/measures/data.c
Normal file
66
src/fsm/measures/data.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* @file
|
||||
* a list of available measurements, including those currently in use
|
||||
*
|
||||
* This file is part of Gem-graph. The operations that can be performed on the
|
||||
* measurements include: select, copy, edit, erase, parameter
|
||||
* (frequency, variable, etc.)
|
||||
*
|
||||
* @see http://www.gnuplot.info/
|
||||
* @see https://fr.wikipedia.org/wiki/Gnuplot
|
||||
* @see https://fr.wikibooks.org/wiki/Mathc_gnuplot
|
||||
*
|
||||
* @see : fsm/measure/manage.c
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@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 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 <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "../../../include/fsm.h"
|
||||
|
||||
/**
|
||||
* phantom documentation
|
||||
*
|
||||
* @param d
|
||||
* @param *p_data
|
||||
* @param *p_target
|
||||
*/
|
||||
void fsm_add_data (fsm_struct_list_data d, int *p_data, int *p_target) {}
|
||||
|
||||
/**
|
||||
* phantom documentation
|
||||
*
|
||||
* @param d
|
||||
* @param from
|
||||
* @param to
|
||||
*/
|
||||
int fsm_get_data (fsm_struct_list_data d, int from, int to) {return 0;}
|
||||
|
||||
/**
|
||||
* phantom documentation
|
||||
*
|
||||
* @param d
|
||||
* @param *p_data
|
||||
*/
|
||||
void fsm_remove_data (fsm_struct_list_data d, int *p_data) {}
|
||||
|
209
src/fsm/measures/tools.c
Normal file
209
src/fsm/measures/tools.c
Normal file
|
@ -0,0 +1,209 @@
|
|||
/**
|
||||
* @file
|
||||
* fsm measures lists tools (basic functions).
|
||||
*
|
||||
* This file is part of Gem-graph.
|
||||
*
|
||||
* @cond LICENSE
|
||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
|
||||
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
|
||||
* Copyright © 2021-2024 Jean Sirmai <jean@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 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 <http://www.gnu.org/licenses/>.
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../../../include/fsm.h"
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* An editable list of measurements is defined and maintained here */
|
||||
/* (see : fsm/measure/manage.c) */
|
||||
/* - - - */
|
||||
/* Each possible measurement can be activated or silenced */
|
||||
/* - - - */
|
||||
/* The measures relate to */
|
||||
/* - the number of occurrences of a rule or group of rules, */
|
||||
/* - the number of objects or situations before/after the rule was applied, */
|
||||
/* - the time (date) of the event, */
|
||||
/* - the time elapsed between two events, */
|
||||
/* - the occurrence of events C between events A and B, */
|
||||
/* NB This list is non limitative. ex : pattern recognition tools */
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// structure de données : chaque "item" doit comporter :
|
||||
//
|
||||
// - identifiant (clé) (+/- pointeur vers : date de création, auteur,...)
|
||||
//
|
||||
// - type de mesure
|
||||
// les 6 items suivants peuvent documenter l'ensemble de toutes les valeurs
|
||||
// à recueillir pour documenter tous les types de mesure possibles;
|
||||
// tous ces items ne doivent pas être simultanément complétés
|
||||
// mais, si un tableau etait utilisé, il y aurait peu de place perdue;
|
||||
//
|
||||
// - pointeur vers le premier groupe de règles (une au moins)
|
||||
// - pointeur vers un second groupe de règles (une au moins)
|
||||
// - pointeur vers des objets ou situations (un au moins)
|
||||
// - pointeur vers un ensemble d'évènements intercurrents
|
||||
// - date de l'évènement
|
||||
// - durée entre deux évènements
|
||||
//
|
||||
// - mesure active ? + / -
|
||||
// - pointeur vers une liste de mesures similaires
|
||||
// - pointeur vers des données, des représentations de données ?
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* @param **ml
|
||||
* @param value
|
||||
*
|
||||
* @callergraph
|
||||
* @see fsm_tools_list_test()
|
||||
*/
|
||||
void fsm_tools_list_insert (fsm_struct_list_tool **ml, int value)
|
||||
{
|
||||
fsm_struct_list_tool *tmp = NULL;
|
||||
fsm_struct_list_tool *cml = *ml;
|
||||
fsm_struct_list_tool *elem = malloc (sizeof (fsm_struct_list_tool));
|
||||
if (!elem) exit (EXIT_FAILURE);
|
||||
elem->value = value;
|
||||
while (cml && cml->value < value)
|
||||
{
|
||||
tmp = cml;
|
||||
cml = cml->suiv;
|
||||
}
|
||||
elem->suiv = cml;
|
||||
if (tmp) tmp->suiv = elem;
|
||||
else *ml = elem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param **ml
|
||||
*
|
||||
* @callergraph
|
||||
* @see fsm_tools_list_test()
|
||||
*/
|
||||
int fsm_tools_list_pop (fsm_struct_list_tool **ml)
|
||||
{
|
||||
int value;
|
||||
fsm_struct_list_tool *tmp;
|
||||
if (! *ml) return -1;
|
||||
tmp = (*ml)->suiv;
|
||||
value = (*ml)->value;
|
||||
free (*ml);
|
||||
*ml = tmp;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param **ml
|
||||
*
|
||||
* @callergraph
|
||||
* @see fsm_tools_list_test()
|
||||
*/
|
||||
int fsm_tools_list_length (fsm_struct_list_tool *ml)
|
||||
{
|
||||
int n = 0;
|
||||
while (ml)
|
||||
{
|
||||
n++;
|
||||
ml = ml->suiv;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param **ml
|
||||
*
|
||||
* @callergraph
|
||||
* @see fsm_tools_list_test()
|
||||
*/
|
||||
void fsm_tools_list_clear (fsm_struct_list_tool **ml)
|
||||
{
|
||||
fsm_struct_list_tool *tmp;
|
||||
while (*ml)
|
||||
{
|
||||
tmp = (*ml)->suiv;
|
||||
free (*ml);
|
||||
*ml = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param **ml
|
||||
*
|
||||
* @callergraph
|
||||
* @see fsm_tools_list_test()
|
||||
*/
|
||||
void fsm_tools_list_view (fsm_struct_list_tool *ml)
|
||||
{
|
||||
printf ("-------- view measures list (n = %d)\n",
|
||||
fsm_tools_list_length (ml));
|
||||
while(ml)
|
||||
{
|
||||
printf("%d\n", ml->value);
|
||||
ml = ml->suiv;
|
||||
}
|
||||
puts ("--------------");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @callergraph
|
||||
* @see fsm_list_init_measures()()
|
||||
*
|
||||
* @callgraph
|
||||
* @see fsm_add_log()
|
||||
* @see fsm_tools_list_insert()
|
||||
* @see fsm_tools_list_pop()
|
||||
* @see fsm_tools_list_view()
|
||||
* @see fsm_tools_list_clear()
|
||||
*/
|
||||
void fsm_tools_list_test()
|
||||
{
|
||||
fsm_struct_list_tool *ex_tool = NULL;
|
||||
|
||||
FSM_ADD_LOG (INFO, "création d'une liste de 6 elements:");
|
||||
fsm_tools_list_insert (&ex_tool,-3);
|
||||
fsm_tools_list_insert (&ex_tool,5);
|
||||
fsm_tools_list_insert (&ex_tool,-1);
|
||||
fsm_tools_list_insert (&ex_tool,4);
|
||||
fsm_tools_list_insert (&ex_tool,2);
|
||||
fsm_tools_list_insert (&ex_tool,0);
|
||||
fsm_tools_list_view (ex_tool);
|
||||
|
||||
FSM_ADD_LOG (INFO, "retrait des 2 premiers elements:");
|
||||
fsm_tools_list_pop (&ex_tool);
|
||||
fsm_tools_list_pop (&ex_tool);
|
||||
|
||||
FSM_ADD_LOG (INFO, "ajout des 2 elements (3, 1):");
|
||||
fsm_tools_list_insert (&ex_tool, 3);
|
||||
fsm_tools_list_insert (&ex_tool, 1);
|
||||
fsm_tools_list_view (ex_tool);
|
||||
|
||||
fsm_tools_list_clear (&ex_tool);
|
||||
// char string_value [10]; if one wants to check the list length: 0
|
||||
// sprintf(string_value, " (%d)", fsm_tools_list_length (ex_tool));
|
||||
FSM_ADD_LOG (INFO, "clear() > 0 élément restant");
|
||||
}
|
||||
|
|
@ -83,5 +83,8 @@ int main (int argc, char **argv)
|
|||
|
||||
fsm_close();
|
||||
|
||||
// g_object_unref (app); <<< GLib-GObject-CRITICAL **: 07:55:38.063: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue