diff options
author | Karel Kočí <cynerd@email.cz> | 2015-03-26 15:17:05 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-03-26 15:17:05 +0100 |
commit | a457b9823e4c46b5d7bc7d5800008a483502ad32 (patch) | |
tree | 794e88f8a1416e2d317a7aa0af4a1ef973c710fd /scripts/kconfig_parser/symlist.c | |
parent | f91e9e472d50795b6e67dfb3905559800a3bef66 (diff) | |
download | linux-conf-perf-a457b9823e4c46b5d7bc7d5800008a483502ad32.tar.gz linux-conf-perf-a457b9823e4c46b5d7bc7d5800008a483502ad32.tar.bz2 linux-conf-perf-a457b9823e4c46b5d7bc7d5800008a483502ad32.zip |
kconfig_parser moved from programs to scripts
This way all executable code is inside scripts directory.
Diffstat (limited to 'scripts/kconfig_parser/symlist.c')
-rw-r--r-- | scripts/kconfig_parser/symlist.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/kconfig_parser/symlist.c b/scripts/kconfig_parser/symlist.c new file mode 100644 index 0000000..5423163 --- /dev/null +++ b/scripts/kconfig_parser/symlist.c @@ -0,0 +1,49 @@ +#include "symlist.h" + +struct symlist *symlist_create() { + struct symlist *ret; + ret = malloc(sizeof(struct symlist)); + ret->size = 2; + ret->pos = 0; + ret->array = malloc(ret->size * sizeof(struct symlist_el)); + return ret; +} + +void symlist_add(struct symlist *sl, char *name) { + if (sl->pos >= sl->size) { + sl->size *= 2; + sl->array = + realloc(sl->array, sl->size * sizeof(struct symlist_el)); + } + sl->array[sl->pos].id = sl->pos + 1; + sl->array[sl->pos].name = name; + sl->array[sl->pos].be = NULL; + sl->pos++; +} + +struct symlist_el *symlist_find(struct symlist *sl, char *name) { + int i = 0; + while (i < sl->pos) { + if (!strcmp(name, sl->array[i].name)) + return &sl->array[i]; + i++; + } + return NULL; +} + +void symlist_print(struct symlist *sl) { + int i; + for (i = 0; i < sl->pos; i++) { + printf("%d:%s\n", sl->array[i].id, sl->array[i].name); + if (sl->array[i].be != NULL) { + printf(" "); + cnf_printf(sl->array[i].be); + printf("\n"); + } + } +} + +void symlist_free(struct symlist *sl) { + free(sl->array); + free(sl); +} |