summaryrefslogtreecommitdiff
path: root/src/bin/e_path.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-05-25 08:08:44 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-05-25 08:08:44 +0000
commitf618831ce9482f4702ac381eb7857e43db05d009 (patch)
tree96717e012029b02a513b8458ceef7dc861b546c1 /src/bin/e_path.c
parentc56e7f857c741a3af8299f998b5742033d730fac (diff)
fix memory leaks! no more leaks!
SVN revision: 14934
Diffstat (limited to 'src/bin/e_path.c')
-rw-r--r--src/bin/e_path.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/bin/e_path.c b/src/bin/e_path.c
index dabcaf5..b67eea3 100644
--- a/src/bin/e_path.c
+++ b/src/bin/e_path.c
@@ -8,9 +8,6 @@ static void _e_path_free(E_Path *ep);
8static void _e_path_cache_free(E_Path *ep); 8static void _e_path_cache_free(E_Path *ep);
9static Evas_Bool _e_path_cache_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata); 9static Evas_Bool _e_path_cache_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
10 10
11/* local subsystem globals */
12static char _e_path_buf[PATH_MAX] = "";
13
14/* externally accessible functions */ 11/* externally accessible functions */
15E_Path * 12E_Path *
16e_path_new(void) 13e_path_new(void)
@@ -254,18 +251,14 @@ e_path_find(E_Path *ep, const char *file)
254{ 251{
255 Evas_List *l; 252 Evas_List *l;
256 char *str; 253 char *str;
254 char buf[PATH_MAX] = "";
257 255
258 E_OBJECT_CHECK_RETURN(ep, NULL); 256 E_OBJECT_CHECK_RETURN(ep, NULL);
259 E_OBJECT_TYPE_CHECK_RETURN(ep, E_PATH_TYPE, NULL); 257 E_OBJECT_TYPE_CHECK_RETURN(ep, E_PATH_TYPE, NULL);
260 258
261 if (!file) return NULL; 259 if (!file) return NULL;
262 _e_path_buf[0] = 0;
263 str = evas_hash_find(ep->hash, file); 260 str = evas_hash_find(ep->hash, file);
264 if (str) 261 if (str) return strdup(str);
265 {
266 strcpy(_e_path_buf, str);
267 return _e_path_buf;
268 }
269 /* Look in the default dir list */ 262 /* Look in the default dir list */
270 for (l = ep->default_dir_list; l; l = l->next) 263 for (l = ep->default_dir_list; l; l = l->next)
271 { 264 {
@@ -275,17 +268,17 @@ e_path_find(E_Path *ep, const char *file)
275 epd = l->data; 268 epd = l->data;
276 if (epd->dir) 269 if (epd->dir)
277 { 270 {
278 snprintf(_e_path_buf, sizeof(_e_path_buf), "%s/%s", epd->dir, file); 271 snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
279 rp = ecore_file_realpath(_e_path_buf); 272 rp = ecore_file_realpath(buf);
280 if ((rp) && (rp[0] != 0)) 273 if ((rp) && (rp[0] != 0))
281 { 274 {
282 strncpy(_e_path_buf, rp, sizeof(_e_path_buf) - 1); 275 strncpy(buf, rp, sizeof(buf) - 1);
283 _e_path_buf[sizeof(_e_path_buf) - 1] = 0; 276 buf[sizeof(buf) - 1] = 0;
284 free(rp); 277 free(rp);
285 if (evas_hash_size(ep->hash) >= 512) 278 if (evas_hash_size(ep->hash) >= 512)
286 _e_path_cache_free(ep); 279 _e_path_cache_free(ep);
287 ep->hash = evas_hash_add(ep->hash, file, strdup(_e_path_buf)); 280 ep->hash = evas_hash_add(ep->hash, file, strdup(buf));
288 return _e_path_buf; 281 return strdup(buf);
289 } 282 }
290 if (rp) free(rp); 283 if (rp) free(rp);
291 } 284 }
@@ -299,22 +292,22 @@ e_path_find(E_Path *ep, const char *file)
299 epd = l->data; 292 epd = l->data;
300 if (epd->dir) 293 if (epd->dir)
301 { 294 {
302 snprintf(_e_path_buf, sizeof(_e_path_buf), "%s/%s", epd->dir, file); 295 snprintf(buf, sizeof(buf), "%s/%s", epd->dir, file);
303 rp = ecore_file_realpath(_e_path_buf); 296 rp = ecore_file_realpath(buf);
304 if ((rp) && (rp[0] != 0)) 297 if ((rp) && (rp[0] != 0))
305 { 298 {
306 strncpy(_e_path_buf, rp, sizeof(_e_path_buf) - 1); 299 strncpy(buf, rp, sizeof(buf) - 1);
307 _e_path_buf[sizeof(_e_path_buf) - 1] = 0; 300 buf[sizeof(buf) - 1] = 0;
308 free(rp); 301 free(rp);
309 if (evas_hash_size(ep->hash) >= 512) 302 if (evas_hash_size(ep->hash) >= 512)
310 _e_path_cache_free(ep); 303 _e_path_cache_free(ep);
311 ep->hash = evas_hash_add(ep->hash, file, strdup(_e_path_buf)); 304 ep->hash = evas_hash_add(ep->hash, file, strdup(buf));
312 return _e_path_buf; 305 return strdup(buf);
313 } 306 }
314 if (rp) free(rp); 307 if (rp) free(rp);
315 } 308 }
316 } 309 }
317 return _e_path_buf; 310 return NULL;
318} 311}
319 312
320void 313void
@@ -335,7 +328,10 @@ e_path_evas_append(E_Path *ep, Evas *evas)
335 328
336 epd = l->data; 329 epd = l->data;
337 if (epd->dir) evas_font_path_append(evas, epd->dir); 330 if (epd->dir) evas_font_path_append(evas, epd->dir);
331 free(epd->dir);
332 free(epd);
338 } 333 }
334 if (dir_list) evas_list_free(dir_list);
339} 335}
340 336
341/* compine default_list and and user_list int and easy to use list */ 337/* compine default_list and and user_list int and easy to use list */
@@ -411,5 +407,5 @@ static Evas_Bool
411_e_path_cache_free_cb(Evas_Hash *hash __UNUSED__, const char *key __UNUSED__, void *data, void *fdata __UNUSED__) 407_e_path_cache_free_cb(Evas_Hash *hash __UNUSED__, const char *key __UNUSED__, void *data, void *fdata __UNUSED__)
412{ 408{
413 free(data); 409 free(data);
414 return 0; 410 return 1;
415} 411}