diff options
author | Guillaume Friloux <guillaume.friloux@gmail.com> | 2014-01-07 09:41:52 +0100 |
---|---|---|
committer | Guillaume Friloux <guillaume.friloux@gmail.com> | 2014-01-07 09:41:52 +0100 |
commit | f50e10521226133d4608d871fdb12e1521d681ed (patch) | |
tree | 19bc85bca417c2d7bebcd168972fdab8f7be06fb /src | |
parent | eb0c5b558750f6bf7fb699f514f6557843f56b9a (diff) |
Fix the use of Rules_Load for loading each rule that is freed after
listing all the files from the rules directory ... We create a Rule_Load
structure for this now.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/rules/rules_load.c | 20 | ||||
-rw-r--r-- | src/lib/rules/rules_private.h | 13 |
2 files changed, 30 insertions, 3 deletions
diff --git a/src/lib/rules/rules_load.c b/src/lib/rules/rules_load.c index eb36ad6..ca21fe5 100644 --- a/src/lib/rules/rules_load.c +++ b/src/lib/rules/rules_load.c | |||
@@ -24,7 +24,7 @@ void | |||
24 | rules_load_rule(void *data, | 24 | rules_load_rule(void *data, |
25 | Conf *conf) | 25 | Conf *conf) |
26 | { | 26 | { |
27 | Rules_Load *rl; | 27 | Rule_Load *rl; |
28 | Rule *rule; | 28 | Rule *rule; |
29 | Eina_Iterator *it; | 29 | Eina_Iterator *it; |
30 | const char *file, | 30 | const char *file, |
@@ -105,6 +105,7 @@ rules_load_rule(void *data, | |||
105 | rl->cb.progress((void *)rl->cb.data, rl->rules, rule); | 105 | rl->cb.progress((void *)rl->cb.data, rl->rules, rule); |
106 | rl->rules->rules = eina_inlist_append(rl->rules->rules, | 106 | rl->rules->rules = eina_inlist_append(rl->rules->rules, |
107 | EINA_INLIST_GET(rule)); | 107 | EINA_INLIST_GET(rule)); |
108 | free(rl); | ||
108 | } | 109 | } |
109 | 110 | ||
110 | /** | 111 | /** |
@@ -165,15 +166,28 @@ rules_load_ls(void *data, | |||
165 | const Eina_File_Direct_Info *info) | 166 | const Eina_File_Direct_Info *info) |
166 | { | 167 | { |
167 | Rules_Load *rl; | 168 | Rules_Load *rl; |
168 | 169 | Rule_Load *ruleload; | |
169 | rl = data; | 170 | rl = data; |
170 | DBG("rl[%p] Rule file : %s", rl, info->path + info->name_start); | 171 | DBG("rl[%p] Rule file : %s", rl, info->path + info->name_start); |
171 | 172 | ||
172 | /* We load file */ | 173 | /* We load file */ |
174 | ruleload = calloc(1, sizeof(Rule_Load)); | ||
175 | if (!ruleload) | ||
176 | { | ||
177 | ERR("Failed to allocate new Rule_Load structure"); | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | ruleload->rules = rl->rules; | ||
182 | ruleload->cb.progress = rl->cb.progress; | ||
183 | ruleload->cb.done = rl->cb.done; | ||
184 | ruleload->cb.error = rl->cb.error; | ||
185 | ruleload->cb.data = rl->cb.data; | ||
186 | |||
173 | conf_load((char *)info->path, | 187 | conf_load((char *)info->path, |
174 | rules_load_rule, | 188 | rules_load_rule, |
175 | rules_load_rule_error, | 189 | rules_load_rule_error, |
176 | rl); | 190 | ruleload); |
177 | } | 191 | } |
178 | 192 | ||
179 | /** | 193 | /** |
diff --git a/src/lib/rules/rules_private.h b/src/lib/rules/rules_private.h index 1d74d95..2042e93 100644 --- a/src/lib/rules/rules_private.h +++ b/src/lib/rules/rules_private.h | |||
@@ -27,6 +27,19 @@ typedef struct _Rules_Load | |||
27 | } cb; | 27 | } cb; |
28 | } Rules_Load; | 28 | } Rules_Load; |
29 | 29 | ||
30 | typedef struct _Rule_Load | ||
31 | { | ||
32 | Rules *rules; | ||
33 | |||
34 | struct | ||
35 | { | ||
36 | Rules_Progress_Cb progress; | ||
37 | Rules_Done_Cb done; | ||
38 | Rules_Error_Cb error; | ||
39 | const void *data; | ||
40 | } cb; | ||
41 | } Rule_Load; | ||
42 | |||
30 | Eina_Bool rules_load_ls_filter(void *data, Eio_File *handler, const Eina_File_Direct_Info *info); | 43 | Eina_Bool rules_load_ls_filter(void *data, Eio_File *handler, const Eina_File_Direct_Info *info); |
31 | void rules_load_ls(void *data, Eio_File *handler, const Eina_File_Direct_Info *info); | 44 | void rules_load_ls(void *data, Eio_File *handler, const Eina_File_Direct_Info *info); |
32 | void rules_load_ls_done(void *data, Eio_File *handler); | 45 | void rules_load_ls_done(void *data, Eio_File *handler); |