aboutsummaryrefslogtreecommitdiff
path: root/scripts/parse_kconfig/symlist.c
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-04-11 13:18:07 +0200
committerKarel Kočí <cynerd@email.cz>2015-04-11 13:18:07 +0200
commitdc3c959a5f6d74e91f9a2d997d20e47b07b65628 (patch)
tree6010f883f1b916d004c64b8c88d8938cf10e3dcb /scripts/parse_kconfig/symlist.c
parentef33b81dfe8fe8b3b161618b4a7f48fc196b105d (diff)
downloadlinux-conf-perf-dc3c959a5f6d74e91f9a2d997d20e47b07b65628.tar.gz
linux-conf-perf-dc3c959a5f6d74e91f9a2d997d20e47b07b65628.tar.bz2
linux-conf-perf-dc3c959a5f6d74e91f9a2d997d20e47b07b65628.zip
Kconfig_parser renamed to parse_kconfig
Diffstat (limited to 'scripts/parse_kconfig/symlist.c')
-rw-r--r--scripts/parse_kconfig/symlist.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/parse_kconfig/symlist.c b/scripts/parse_kconfig/symlist.c
new file mode 100644
index 0000000..5423163
--- /dev/null
+++ b/scripts/parse_kconfig/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);
+}