summaryrefslogtreecommitdiff
path: root/src/bin/e_path.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2009-08-21 15:08:49 +0000
committerCedric BAIL <cedric.bail@free.fr>2009-08-21 15:08:49 +0000
commitf8c05999e4b6df682bfb2bf4568fe0350d272cf3 (patch)
treea42f8a5d2868027223020c3d4a0c069d99d1f823 /src/bin/e_path.c
parentb1225d525148a873794842807953ac18e8832a48 (diff)
* e: Cleanup use of Eina data structure.
Patch from Peter van de Werken <pwerken-e@a-eskwadraat.nl>. SVN revision: 41916
Diffstat (limited to '')
-rw-r--r--src/bin/e_path.c49
1 files changed, 15 insertions, 34 deletions
diff --git a/src/bin/e_path.c b/src/bin/e_path.c
index 801199d..df8a39c 100644
--- a/src/bin/e_path.c
+++ b/src/bin/e_path.c
@@ -161,6 +161,7 @@ EAPI void
161e_path_user_path_remove(E_Path *ep, const char *path) 161e_path_user_path_remove(E_Path *ep, const char *path)
162{ 162{
163 Eina_List *l; 163 Eina_List *l;
164 E_Path_Dir *epd;
164 165
165 E_OBJECT_CHECK(ep); 166 E_OBJECT_CHECK(ep);
166 E_OBJECT_TYPE_CHECK(ep, E_PATH_TYPE); 167 E_OBJECT_TYPE_CHECK(ep, E_PATH_TYPE);
@@ -178,11 +179,8 @@ e_path_user_path_remove(E_Path *ep, const char *path)
178 if (!new_path) return; 179 if (!new_path) return;
179 strcpy(new_path, home_dir); 180 strcpy(new_path, home_dir);
180 strcat(new_path, path + 1); 181 strcat(new_path, path + 1);
181 for (l = *(ep->user_dir_list); l; l = l->next) 182 EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
182 { 183 {
183 E_Path_Dir *epd;
184
185 epd = l->data;
186 if (epd->dir) 184 if (epd->dir)
187 { 185 {
188 if (!strcmp(epd->dir, new_path)) 186 if (!strcmp(epd->dir, new_path))
@@ -201,10 +199,8 @@ e_path_user_path_remove(E_Path *ep, const char *path)
201 } 199 }
202 else 200 else
203 { 201 {
204 for (l = *(ep->user_dir_list); l; l = l->next) 202 EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
205 { 203 {
206 E_Path_Dir *epd;
207 epd = l->data;
208 if (epd->dir) 204 if (epd->dir)
209 { 205 {
210 if (!strcmp(epd->dir, path)) 206 if (!strcmp(epd->dir, path))
@@ -223,12 +219,10 @@ e_path_user_path_remove(E_Path *ep, const char *path)
223 219
224EAPI void 220EAPI void
225e_path_user_path_clear(E_Path *ep) 221e_path_user_path_clear(E_Path *ep)
226{ 222{
227 while (*(ep->user_dir_list)) 223 E_Path_Dir *epd;
224 EINA_LIST_FREE(*(ep->user_dir_list), epd)
228 { 225 {
229 E_Path_Dir *epd;
230 epd = (*(ep->user_dir_list))->data;
231 *(ep->user_dir_list) = eina_list_remove_list(*(ep->user_dir_list), *(ep->user_dir_list));
232 eina_stringshare_del(epd->dir); 226 eina_stringshare_del(epd->dir);
233 free(epd); 227 free(epd);
234 } 228 }
@@ -268,11 +262,8 @@ e_path_find(E_Path *ep, const char *file)
268 } 262 }
269 } 263 }
270 /* Look in the users dir list */ 264 /* Look in the users dir list */
271 for (l = *(ep->user_dir_list); l; l = l->next) 265 EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
272 { 266 {
273 E_Path_Dir *epd;
274
275 epd = l->data;
276 if (epd->dir) 267 if (epd->dir)
277 { 268 {
278 snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file); 269 snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
@@ -294,8 +285,8 @@ e_path_find(E_Path *ep, const char *file)
294EAPI void 285EAPI void
295e_path_evas_append(E_Path *ep, Evas *evas) 286e_path_evas_append(E_Path *ep, Evas *evas)
296{ 287{
297 Eina_List *l;
298 Eina_List *dir_list; 288 Eina_List *dir_list;
289 E_Path_Dir *epd;
299 290
300 E_OBJECT_CHECK(ep); 291 E_OBJECT_CHECK(ep);
301 E_OBJECT_TYPE_CHECK(ep, E_PATH_TYPE); 292 E_OBJECT_TYPE_CHECK(ep, E_PATH_TYPE);
@@ -303,16 +294,12 @@ e_path_evas_append(E_Path *ep, Evas *evas)
303 294
304 dir_list = e_path_dir_list_get(ep); 295 dir_list = e_path_dir_list_get(ep);
305 296
306 for (l = dir_list; l; l = l->next) 297 EINA_LIST_FREE(dir_list, epd)
307 { 298 {
308 E_Path_Dir *epd;
309
310 epd = l->data;
311 if (epd->dir) evas_font_path_append(evas, epd->dir); 299 if (epd->dir) evas_font_path_append(evas, epd->dir);
312 eina_stringshare_del(epd->dir); 300 eina_stringshare_del(epd->dir);
313 free(epd); 301 free(epd);
314 } 302 }
315 if (dir_list) eina_list_free(dir_list);
316} 303}
317 304
318/* combine default_list and and user_list in and easy to use list */ 305/* combine default_list and and user_list in and easy to use list */
@@ -328,18 +315,16 @@ e_path_dir_list_get(E_Path *ep)
328 315
329 if (ep->user_dir_list) 316 if (ep->user_dir_list)
330 { 317 {
331 for (l = *(ep->user_dir_list); l; l = l->next) 318 EINA_LIST_FOREACH(*(ep->user_dir_list), l, epd)
332 { 319 {
333 epd = l->data;
334 new_epd = malloc(sizeof(E_Path_Dir)); 320 new_epd = malloc(sizeof(E_Path_Dir));
335 new_epd->dir = eina_stringshare_add(epd->dir); 321 new_epd->dir = eina_stringshare_add(epd->dir);
336 dir_list = eina_list_append(dir_list, new_epd); 322 dir_list = eina_list_append(dir_list, new_epd);
337 } 323 }
338 } 324 }
339 325
340 for (l = ep->default_dir_list; l; l = l->next) 326 EINA_LIST_FOREACH(ep->default_dir_list, l, epd)
341 { 327 {
342 epd = l->data;
343 new_epd = malloc(sizeof(E_Path_Dir)); 328 new_epd = malloc(sizeof(E_Path_Dir));
344 new_epd->dir = eina_stringshare_add(epd->dir); 329 new_epd->dir = eina_stringshare_add(epd->dir);
345 dir_list = eina_list_append(dir_list, new_epd); 330 dir_list = eina_list_append(dir_list, new_epd);
@@ -353,10 +338,8 @@ e_path_dir_list_free(Eina_List *dir_list)
353{ 338{
354 E_Path_Dir *epd; 339 E_Path_Dir *epd;
355 340
356 while (dir_list) 341 EINA_LIST_FREE(dir_list, epd)
357 { 342 {
358 epd = dir_list->data;
359 dir_list = eina_list_remove_list(dir_list, dir_list);
360 eina_stringshare_del(epd->dir); 343 eina_stringshare_del(epd->dir);
361 free(epd); 344 free(epd);
362 } 345 }
@@ -366,15 +349,13 @@ e_path_dir_list_free(Eina_List *dir_list)
366static void 349static void
367_e_path_free(E_Path *ep) 350_e_path_free(E_Path *ep)
368{ 351{
352 E_Path_Dir *epd;
353
369 _e_path_cache_free(ep); 354 _e_path_cache_free(ep);
370 while (ep->default_dir_list) 355 EINA_LIST_FREE(ep->default_dir_list, epd)
371 { 356 {
372 E_Path_Dir *epd;
373 epd = ep->default_dir_list->data;
374 eina_stringshare_del(epd->dir); 357 eina_stringshare_del(epd->dir);
375 free(epd); 358 free(epd);
376 ep->default_dir_list = eina_list_remove_list(ep->default_dir_list,
377 ep->default_dir_list);
378 } 359 }
379 free(ep); 360 free(ep);
380} 361}