diff options
author | sebastid <sebastid> | 2006-09-22 19:55:11 +0000 |
---|---|---|
committer | sebastid <sebastid@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2006-09-22 19:55:11 +0000 |
commit | 1251802479a2da37f320cfaeda58d04aa69e3074 (patch) | |
tree | 81c64ff0488b79f1f4f19b52eb2be0ab2c508dd7 /src/bin/e_path.c | |
parent | d7ac0581379c479a302a88e09ae3e25ac43482d0 (diff) |
Don't strdup homedir
SVN revision: 26026
Diffstat (limited to '')
-rw-r--r-- | src/bin/e_path.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/src/bin/e_path.c b/src/bin/e_path.c index 67de09d..d953f25 100644 --- a/src/bin/e_path.c +++ b/src/bin/e_path.c | |||
@@ -28,23 +28,17 @@ e_path_default_path_append(E_Path *ep, const char *path) | |||
28 | { | 28 | { |
29 | E_Path_Dir *epd; | 29 | E_Path_Dir *epd; |
30 | char *new_path; | 30 | char *new_path; |
31 | char *home_dir; | 31 | const char *home_dir; |
32 | int len1, len2; | 32 | int len1, len2; |
33 | 33 | ||
34 | home_dir = e_user_homedir_get(); | 34 | home_dir = e_user_homedir_get(); |
35 | if (!home_dir) return; | ||
36 | len1 = strlen(home_dir); | 35 | len1 = strlen(home_dir); |
37 | len2 = strlen(path); | 36 | len2 = strlen(path); |
38 | new_path = malloc(len1 + len2 + 1); | 37 | new_path = malloc(len1 + len2 + 1); |
39 | if (!new_path) | 38 | if (!new_path) return; |
40 | { | ||
41 | free(home_dir); | ||
42 | return; | ||
43 | } | ||
44 | epd = malloc(sizeof(E_Path_Dir)); | 39 | epd = malloc(sizeof(E_Path_Dir)); |
45 | if (!epd) | 40 | if (!epd) |
46 | { | 41 | { |
47 | free(home_dir); | ||
48 | free(new_path); | 42 | free(new_path); |
49 | return; | 43 | return; |
50 | } | 44 | } |
@@ -53,7 +47,6 @@ e_path_default_path_append(E_Path *ep, const char *path) | |||
53 | strcat(new_path, path + 1); | 47 | strcat(new_path, path + 1); |
54 | epd->dir = evas_stringshare_add(new_path); | 48 | epd->dir = evas_stringshare_add(new_path); |
55 | free(new_path); | 49 | free(new_path); |
56 | free(home_dir); | ||
57 | ep->default_dir_list = evas_list_append(ep->default_dir_list, epd); | 50 | ep->default_dir_list = evas_list_append(ep->default_dir_list, epd); |
58 | } | 51 | } |
59 | else | 52 | else |
@@ -89,23 +82,17 @@ e_path_user_path_append(E_Path *ep, const char *path) | |||
89 | { | 82 | { |
90 | E_Path_Dir *epd; | 83 | E_Path_Dir *epd; |
91 | char *new_path; | 84 | char *new_path; |
92 | char *home_dir; | 85 | const char *home_dir; |
93 | int len1, len2; | 86 | int len1, len2; |
94 | 87 | ||
95 | home_dir = e_user_homedir_get(); | 88 | home_dir = e_user_homedir_get(); |
96 | if (!home_dir) return; | ||
97 | len1 = strlen(home_dir); | 89 | len1 = strlen(home_dir); |
98 | len2 = strlen(path); | 90 | len2 = strlen(path); |
99 | new_path = malloc(len1 + len2 + 1); | 91 | new_path = malloc(len1 + len2 + 1); |
100 | if (!new_path) | 92 | if (!new_path) return; |
101 | { | ||
102 | free(home_dir); | ||
103 | return; | ||
104 | } | ||
105 | epd = malloc(sizeof(E_Path_Dir)); | 93 | epd = malloc(sizeof(E_Path_Dir)); |
106 | if (!epd) | 94 | if (!epd) |
107 | { | 95 | { |
108 | free(home_dir); | ||
109 | free(new_path); | 96 | free(new_path); |
110 | return; | 97 | return; |
111 | } | 98 | } |
@@ -114,7 +101,6 @@ e_path_user_path_append(E_Path *ep, const char *path) | |||
114 | strcat(new_path, path + 1); | 101 | strcat(new_path, path + 1); |
115 | epd->dir = evas_stringshare_add(new_path); | 102 | epd->dir = evas_stringshare_add(new_path); |
116 | free(new_path); | 103 | free(new_path); |
117 | free(home_dir); | ||
118 | *(ep->user_dir_list) = evas_list_append(*(ep->user_dir_list), epd); | 104 | *(ep->user_dir_list) = evas_list_append(*(ep->user_dir_list), epd); |
119 | } | 105 | } |
120 | else | 106 | else |
@@ -139,23 +125,17 @@ e_path_user_path_prepend(E_Path *ep, const char *path) | |||
139 | { | 125 | { |
140 | E_Path_Dir *epd; | 126 | E_Path_Dir *epd; |
141 | char *new_path; | 127 | char *new_path; |
142 | char *home_dir; | 128 | const char *home_dir; |
143 | int len1, len2; | 129 | int len1, len2; |
144 | 130 | ||
145 | home_dir = e_user_homedir_get(); | 131 | home_dir = e_user_homedir_get(); |
146 | if (!home_dir) return; | ||
147 | len1 = strlen(home_dir); | 132 | len1 = strlen(home_dir); |
148 | len2 = strlen(path); | 133 | len2 = strlen(path); |
149 | new_path = malloc(len1 + len2 + 1); | 134 | new_path = malloc(len1 + len2 + 1); |
150 | if (!new_path) | 135 | if (!new_path) return; |
151 | { | ||
152 | free(home_dir); | ||
153 | return; | ||
154 | } | ||
155 | epd = malloc(sizeof(E_Path_Dir)); | 136 | epd = malloc(sizeof(E_Path_Dir)); |
156 | if (!epd) | 137 | if (!epd) |
157 | { | 138 | { |
158 | free(home_dir); | ||
159 | free(new_path); | 139 | free(new_path); |
160 | return; | 140 | return; |
161 | } | 141 | } |
@@ -164,7 +144,6 @@ e_path_user_path_prepend(E_Path *ep, const char *path) | |||
164 | strcat(new_path, path + 1); | 144 | strcat(new_path, path + 1); |
165 | epd->dir = evas_stringshare_add(new_path); | 145 | epd->dir = evas_stringshare_add(new_path); |
166 | free(new_path); | 146 | free(new_path); |
167 | free(home_dir); | ||
168 | *(ep->user_dir_list) = evas_list_prepend(*(ep->user_dir_list), epd); | 147 | *(ep->user_dir_list) = evas_list_prepend(*(ep->user_dir_list), epd); |
169 | } | 148 | } |
170 | else | 149 | else |
@@ -190,22 +169,16 @@ e_path_user_path_remove(E_Path *ep, const char *path) | |||
190 | if (path[0] == '~') | 169 | if (path[0] == '~') |
191 | { | 170 | { |
192 | char *new_path; | 171 | char *new_path; |
193 | char *home_dir; | 172 | const char *home_dir; |
194 | int len1, len2; | 173 | int len1, len2; |
195 | 174 | ||
196 | home_dir = e_user_homedir_get(); | 175 | home_dir = e_user_homedir_get(); |
197 | if (!home_dir) return; | ||
198 | len1 = strlen(home_dir); | 176 | len1 = strlen(home_dir); |
199 | len2 = strlen(path); | 177 | len2 = strlen(path); |
200 | new_path = malloc(len1 + len2 + 1); | 178 | new_path = malloc(len1 + len2 + 1); |
201 | if (!new_path) | 179 | if (!new_path) return; |
202 | { | ||
203 | free(home_dir); | ||
204 | return; | ||
205 | } | ||
206 | strcpy(new_path, home_dir); | 180 | strcpy(new_path, home_dir); |
207 | strcat(new_path, path + 1); | 181 | strcat(new_path, path + 1); |
208 | free(home_dir); | ||
209 | for (l = *(ep->user_dir_list); l; l = l->next) | 182 | for (l = *(ep->user_dir_list); l; l = l->next) |
210 | { | 183 | { |
211 | E_Path_Dir *epd; | 184 | E_Path_Dir *epd; |