From 5e2df60d66d601f327d9c31e1880806aee6eb2e4 Mon Sep 17 00:00:00 2001 From: Emmanuel Mogenet Date: Sun, 16 Apr 2017 21:22:16 +0200 Subject: Move skip flag to its own array in ghwlib --- src/grt/ghwlib.c | 79 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 33 deletions(-) (limited to 'src/grt/ghwlib.c') diff --git a/src/grt/ghwlib.c b/src/grt/ghwlib.c index 4ac721ee0..c16936b1e 100644 --- a/src/grt/ghwlib.c +++ b/src/grt/ghwlib.c @@ -839,6 +839,7 @@ ghw_read_hie (struct ghw_handler *h) h->hie = blk; h->nbr_sigs++; + h->skip_sigs = NULL; h->sigs = (struct ghw_sig *) malloc (h->nbr_sigs * sizeof (struct ghw_sig)); memset (h->sigs, 0, h->nbr_sigs * sizeof (struct ghw_sig)); @@ -1345,45 +1346,57 @@ ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type) } } -static int -is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal) -{ - int i; - - for (i = 0; i < nb_signals_to_keep; ++i) - { - if (signal==signals_to_keep[i]) - return 0; +static char is_skip_signal( + int *signals_to_keep, + int nb_signals_to_keep, + int signal +) { + int i; + for(i=0; inbr_sigs; ++i) - { - struct ghw_sig *s = &(h->sigs[i]); - s->skip = is_skip_signal (signals_to_keep, nb_signals_to_keep, i); +void ghw_filter_signals( + struct ghw_handler *h, + int *signals_to_keep, + int nb_signals_to_keep +) { + int i; + if(0skip_sigs) { + h->skip_sigs = (char*)malloc(sizeof(char)*h->nbr_sigs); + } + for(i=0; inbr_sigs; ++i) { + h->skip_sigs[i] = is_skip_signal( + signals_to_keep, + nb_signals_to_keep, + i + ); + } + } else { + if(0!=h->skip_sigs) { + free(h->skip_sigs); + h->skip_sigs = 0; + } } } -void -ghw_disp_values (struct ghw_handler *h) -{ - int i; - - for (i = 0; i < h->nbr_sigs; i++) - { - struct ghw_sig *s = &h->sigs[i]; - if (s->type != NULL && !(s->skip)) - { - printf ("#%d: ", i); - ghw_disp_value (s->val, s->type); - printf ("\n"); - } +void ghw_disp_values( + struct ghw_handler *h +) { + int i; + for (i = 0; i < h->nbr_sigs; i++) { + struct ghw_sig *s = &h->sigs[i]; + int skip = (0!=h->skip_sigs && (0!=h->skip_sigs[i])); + if(s->type != NULL && !skip) { + printf ("#%d: ", i); + ghw_disp_value (s->val, s->type); + printf ("\n"); + } } } -- cgit v1.2.3 From ba52acf5442bfdc69bd8ef3f8aee88b6af4a73c5 Mon Sep 17 00:00:00 2001 From: Emmanuel Mogenet Date: Sun, 16 Apr 2017 22:05:07 +0200 Subject: Feed new code through indent to match indigenous style --- src/grt/ghwlib.c | 95 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 46 deletions(-) (limited to 'src/grt/ghwlib.c') diff --git a/src/grt/ghwlib.c b/src/grt/ghwlib.c index c16936b1e..bee84687c 100644 --- a/src/grt/ghwlib.c +++ b/src/grt/ghwlib.c @@ -1346,60 +1346,63 @@ ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type) } } -static char is_skip_signal( - int *signals_to_keep, - int nb_signals_to_keep, - int signal -) { - int i; - for(i=0; iskip_sigs) { - h->skip_sigs = (char*)malloc(sizeof(char)*h->nbr_sigs); - } - for(i=0; inbr_sigs; ++i) { - h->skip_sigs[i] = is_skip_signal( - signals_to_keep, - nb_signals_to_keep, - i - ); - } - } else { - if(0!=h->skip_sigs) { - free(h->skip_sigs); - h->skip_sigs = 0; - } +void +ghw_filter_signals (struct ghw_handler *h, + int *signals_to_keep, int nb_signals_to_keep) +{ + int i; + if (0 < nb_signals_to_keep && 0 != signals_to_keep) + { + if (0 == h->skip_sigs) + { + h->skip_sigs = (char *) malloc (sizeof (char) * h->nbr_sigs); + } + for (i = 0; i < h->nbr_sigs; ++i) + { + h->skip_sigs[i] = is_skip_signal (signals_to_keep, + nb_signals_to_keep, i); + } + } + else + { + if (0 != h->skip_sigs) + { + free (h->skip_sigs); + h->skip_sigs = 0; + } } } -void ghw_disp_values( - struct ghw_handler *h -) { - int i; - for (i = 0; i < h->nbr_sigs; i++) { - struct ghw_sig *s = &h->sigs[i]; - int skip = (0!=h->skip_sigs && (0!=h->skip_sigs[i])); - if(s->type != NULL && !skip) { - printf ("#%d: ", i); - ghw_disp_value (s->val, s->type); - printf ("\n"); - } +void +ghw_disp_values (struct ghw_handler *h) +{ + int i; + for (i = 0; i < h->nbr_sigs; i++) + { + struct ghw_sig *s = &h->sigs[i]; + int skip = (0 != h->skip_sigs && (0 != h->skip_sigs[i])); + if (s->type != NULL && !skip) + { + printf ("#%d: ", i); + ghw_disp_value (s->val, s->type); + printf ("\n"); + } } } - int ghw_read_directory (struct ghw_handler *h) { -- cgit v1.2.3