summaryrefslogtreecommitdiff
path: root/src/bin/e_path.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-12-03 15:39:25 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-12-03 15:39:25 +0000
commitd8c635f964a0de8d06c1460546993063bec36136 (patch)
tree5a2d57ddbb720bebd16a8ffefe208937bf446684 /src/bin/e_path.c
parent2f655c348d808577e1723d3360a9ea6807dd1378 (diff)
more stringshare work
SVN revision: 18816
Diffstat (limited to 'src/bin/e_path.c')
-rw-r--r--src/bin/e_path.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/bin/e_path.c b/src/bin/e_path.c
index 4dbb64a..462bbd0 100644
--- a/src/bin/e_path.c
+++ b/src/bin/e_path.c
@@ -49,9 +49,10 @@ e_path_default_path_append(E_Path *ep, const char *path)
49 return; 49 return;
50 } 50 }
51 51
52 epd->dir = new_path;
53 strcpy(new_path, home_dir); 52 strcpy(new_path, home_dir);
54 strcat(new_path, path + 1); 53 strcat(new_path, path + 1);
54 epd->dir = evas_stringshare_add(new_path);
55 free(new_path);
55 free(home_dir); 56 free(home_dir);
56 ep->default_dir_list = evas_list_append(ep->default_dir_list, epd); 57 ep->default_dir_list = evas_list_append(ep->default_dir_list, epd);
57 } 58 }
@@ -61,7 +62,7 @@ e_path_default_path_append(E_Path *ep, const char *path)
61 epd = malloc(sizeof(E_Path_Dir)); 62 epd = malloc(sizeof(E_Path_Dir));
62 if (!epd) 63 if (!epd)
63 return; 64 return;
64 epd->dir = strdup(path); 65 epd->dir = evas_stringshare_add(path);
65 ep->default_dir_list = evas_list_append(ep->default_dir_list, epd); 66 ep->default_dir_list = evas_list_append(ep->default_dir_list, epd);
66 } 67 }
67 _e_path_cache_free(ep); 68 _e_path_cache_free(ep);
@@ -109,9 +110,10 @@ e_path_user_path_append(E_Path *ep, const char *path)
109 return; 110 return;
110 } 111 }
111 112
112 epd->dir = new_path;
113 strcpy(new_path, home_dir); 113 strcpy(new_path, home_dir);
114 strcat(new_path, path + 1); 114 strcat(new_path, path + 1);
115 epd->dir = evas_stringshare_add(new_path);
116 free(new_path);
115 free(home_dir); 117 free(home_dir);
116 *(ep->user_dir_list) = evas_list_append(*(ep->user_dir_list), epd); 118 *(ep->user_dir_list) = evas_list_append(*(ep->user_dir_list), epd);
117 } 119 }
@@ -121,7 +123,7 @@ e_path_user_path_append(E_Path *ep, const char *path)
121 epd = malloc(sizeof(E_Path_Dir)); 123 epd = malloc(sizeof(E_Path_Dir));
122 if (!epd) 124 if (!epd)
123 return; 125 return;
124 epd->dir = strdup(path); 126 epd->dir = evas_stringshare_add(path);
125 *(ep->user_dir_list) = evas_list_append(*(ep->user_dir_list), epd); 127 *(ep->user_dir_list) = evas_list_append(*(ep->user_dir_list), epd);
126 } 128 }
127 _e_path_cache_free(ep); 129 _e_path_cache_free(ep);
@@ -158,9 +160,10 @@ e_path_user_path_prepend(E_Path *ep, const char *path)
158 return; 160 return;
159 } 161 }
160 162
161 epd->dir = new_path;
162 strcpy(new_path, home_dir); 163 strcpy(new_path, home_dir);
163 strcat(new_path, path + 1); 164 strcat(new_path, path + 1);
165 epd->dir = evas_stringshare_add(new_path);
166 free(new_path);
164 free(home_dir); 167 free(home_dir);
165 *(ep->user_dir_list) = evas_list_prepend(*(ep->user_dir_list), epd); 168 *(ep->user_dir_list) = evas_list_prepend(*(ep->user_dir_list), epd);
166 } 169 }
@@ -170,7 +173,7 @@ e_path_user_path_prepend(E_Path *ep, const char *path)
170 epd = malloc(sizeof(E_Path_Dir)); 173 epd = malloc(sizeof(E_Path_Dir));
171 if (!epd) 174 if (!epd)
172 return; 175 return;
173 epd->dir = strdup(path); 176 epd->dir = evas_stringshare_add(path);
174 *(ep->user_dir_list) = evas_list_prepend(*(ep->user_dir_list), epd); 177 *(ep->user_dir_list) = evas_list_prepend(*(ep->user_dir_list), epd);
175 } 178 }
176 _e_path_cache_free(ep); 179 _e_path_cache_free(ep);
@@ -214,7 +217,7 @@ e_path_user_path_remove(E_Path *ep, const char *path)
214 { 217 {
215 *(ep->user_dir_list) = evas_list_remove_list( 218 *(ep->user_dir_list) = evas_list_remove_list(
216 *(ep->user_dir_list), l); 219 *(ep->user_dir_list), l);
217 free(epd->dir); 220 evas_stringshare_del(epd->dir);
218 free(epd); 221 free(epd);
219 free(new_path); 222 free(new_path);
220 _e_path_cache_free(ep); 223 _e_path_cache_free(ep);
@@ -236,7 +239,7 @@ e_path_user_path_remove(E_Path *ep, const char *path)
236 { 239 {
237 *(ep->user_dir_list) = evas_list_remove_list( 240 *(ep->user_dir_list) = evas_list_remove_list(
238 *(ep->user_dir_list), l); 241 *(ep->user_dir_list), l);
239 free(epd->dir); 242 evas_stringshare_del(epd->dir);
240 free(epd); 243 free(epd);
241 _e_path_cache_free(ep); 244 _e_path_cache_free(ep);
242 return; 245 return;
@@ -277,7 +280,8 @@ e_path_find(E_Path *ep, const char *file)
277 free(rp); 280 free(rp);
278 if (evas_hash_size(ep->hash) >= 512) 281 if (evas_hash_size(ep->hash) >= 512)
279 _e_path_cache_free(ep); 282 _e_path_cache_free(ep);
280 ep->hash = evas_hash_add(ep->hash, file, strdup(buf)); 283 ep->hash = evas_hash_add(ep->hash, file,
284 evas_stringshare_add(buf));
281 return strdup(buf); 285 return strdup(buf);
282 } 286 }
283 if (rp) free(rp); 287 if (rp) free(rp);
@@ -301,7 +305,8 @@ e_path_find(E_Path *ep, const char *file)
301 free(rp); 305 free(rp);
302 if (evas_hash_size(ep->hash) >= 512) 306 if (evas_hash_size(ep->hash) >= 512)
303 _e_path_cache_free(ep); 307 _e_path_cache_free(ep);
304 ep->hash = evas_hash_add(ep->hash, file, strdup(buf)); 308 ep->hash = evas_hash_add(ep->hash, file,
309 evas_stringshare_add(buf));
305 return strdup(buf); 310 return strdup(buf);
306 } 311 }
307 if (rp) free(rp); 312 if (rp) free(rp);
@@ -328,7 +333,7 @@ e_path_evas_append(E_Path *ep, Evas *evas)
328 333
329 epd = l->data; 334 epd = l->data;
330 if (epd->dir) evas_font_path_append(evas, epd->dir); 335 if (epd->dir) evas_font_path_append(evas, epd->dir);
331 free(epd->dir); 336 evas_stringshare_del(epd->dir);
332 free(epd); 337 free(epd);
333 } 338 }
334 if (dir_list) evas_list_free(dir_list); 339 if (dir_list) evas_list_free(dir_list);
@@ -351,7 +356,7 @@ e_path_dir_list_get(E_Path *ep)
351 { 356 {
352 epd = l->data; 357 epd = l->data;
353 new_epd = malloc(sizeof(E_Path_Dir)); 358 new_epd = malloc(sizeof(E_Path_Dir));
354 new_epd->dir = strdup(epd->dir); 359 new_epd->dir = evas_stringshare_add(epd->dir);
355 dir_list = evas_list_append(dir_list, new_epd); 360 dir_list = evas_list_append(dir_list, new_epd);
356 } 361 }
357 } 362 }
@@ -360,7 +365,7 @@ e_path_dir_list_get(E_Path *ep)
360 { 365 {
361 epd = l->data; 366 epd = l->data;
362 new_epd = malloc(sizeof(E_Path_Dir)); 367 new_epd = malloc(sizeof(E_Path_Dir));
363 new_epd->dir = strdup(epd->dir); 368 new_epd->dir = evas_stringshare_add(epd->dir);
364 dir_list = evas_list_append(dir_list, new_epd); 369 dir_list = evas_list_append(dir_list, new_epd);
365 } 370 }
366 371
@@ -376,7 +381,7 @@ e_path_dir_list_free(Evas_List *dir_list)
376 { 381 {
377 epd = dir_list->data; 382 epd = dir_list->data;
378 dir_list = evas_list_remove_list(dir_list, dir_list); 383 dir_list = evas_list_remove_list(dir_list, dir_list);
379 free(epd->dir); 384 evas_stringshare_del(epd->dir);
380 free(epd); 385 free(epd);
381 } 386 }
382} 387}
@@ -390,10 +395,10 @@ _e_path_free(E_Path *ep)
390 { 395 {
391 E_Path_Dir *epd; 396 E_Path_Dir *epd;
392 epd = ep->default_dir_list->data; 397 epd = ep->default_dir_list->data;
393 free(epd->dir); 398 evas_stringshare_del(epd->dir);
394 free(epd); 399 free(epd);
395 ep->default_dir_list = evas_list_remove_list(ep->default_dir_list, 400 ep->default_dir_list = evas_list_remove_list(ep->default_dir_list,
396 ep->default_dir_list); 401 ep->default_dir_list);
397 } 402 }
398 free(ep); 403 free(ep);
399} 404}
@@ -410,6 +415,6 @@ _e_path_cache_free(E_Path *ep)
410static Evas_Bool 415static Evas_Bool
411_e_path_cache_free_cb(Evas_Hash *hash __UNUSED__, const char *key __UNUSED__, void *data, void *fdata __UNUSED__) 416_e_path_cache_free_cb(Evas_Hash *hash __UNUSED__, const char *key __UNUSED__, void *data, void *fdata __UNUSED__)
412{ 417{
413 free(data); 418 evas_stringshare_del(data);
414 return 1; 419 return 1;
415} 420}