@@ -70,22 +70,20 @@ int remote_to_local(xdebug_path_maps *maps, const char *remote_path, size_t remo
7070{
7171 xdebug_path_mapping * result ;
7272 xdebug_hash * map = maps -> remote_to_local_map ;
73- char * url_path = xdebug_normalize_path_char (remote_path );
7473
75- if (!xdebug_hash_find (map , url_path , strlen (url_path ), (void * * ) & result )) {
74+ if (!xdebug_hash_find (map , remote_path , strlen (remote_path ), (void * * ) & result )) {
7675 /* We can't find an exact file match, so now try to see if we have a directory match, starting with the full
7776 * path and then removing the trailing directory path until there are none left */
7877 char * end_slash ;
7978 char * directory ;
8079
81- end_slash = strrchr ((char * ) url_path , '/' );
80+ end_slash = strrchr ((char * ) remote_path , DEFAULT_SLASH );
8281 if (!end_slash ) {
83- xdfree (url_path );
8482 return XDEBUG_PATH_MAP_TYPE_UNKNOWN ;
8583 }
8684
87- directory = xdstrndup (url_path , end_slash - url_path + 1 );
88- end_slash = strrchr ((char * ) directory , '/' );
85+ directory = xdstrndup (remote_path , end_slash - remote_path + 1 );
86+ end_slash = strrchr ((char * ) directory , DEFAULT_SLASH );
8987
9088 do {
9189 size_t n = end_slash - directory + 1 ;
@@ -100,19 +98,17 @@ int remote_to_local(xdebug_path_maps *maps, const char *remote_path, size_t remo
10098 * local_line = remote_line ;
10199
102100 * local_path = xdebug_str_new ();
103- xdebug_str_add_fmt (* local_path , "%s%s" , result -> m .local_path -> d , url_path + n );
101+ xdebug_str_add_fmt (* local_path , "%s%s" , result -> m .local_path -> d , remote_path + n );
104102
105103 xdfree (directory );
106- xdfree (url_path );
107104 return XDEBUG_PATH_MAP_TYPE_DIRECTORY ;
108105 }
109106 }
110107
111- end_slash = strrnchr (directory , '/' , n - 1 );
108+ end_slash = strrnchr (directory , DEFAULT_SLASH , n - 1 );
112109 } while (end_slash );
113110
114111 xdfree (directory );
115- xdfree (url_path );
116112 return XDEBUG_PATH_MAP_TYPE_UNKNOWN ;
117113 }
118114
@@ -138,12 +134,10 @@ int remote_to_local(xdebug_path_maps *maps, const char *remote_path, size_t remo
138134 size_t result_line ;
139135
140136 if (!result -> m .line_ranges ) {
141- xdfree (url_path );
142137 return XDEBUG_PATH_MAP_TYPE_UNKNOWN ;
143138 }
144139
145140 if (!find_local_line_number_from_ranges (remote_line , result -> m .line_ranges , & result_path , & result_line )) {
146- xdfree (url_path );
147141 return XDEBUG_PATH_MAP_TYPE_UNKNOWN ;
148142 }
149143
@@ -154,7 +148,6 @@ int remote_to_local(xdebug_path_maps *maps, const char *remote_path, size_t remo
154148 * local_path = xdebug_str_copy (result_path );
155149 * local_line = result_line ;
156150
157- xdfree (url_path );
158151 return result -> type ;
159152 }
160153
@@ -167,7 +160,6 @@ int remote_to_local(xdebug_path_maps *maps, const char *remote_path, size_t remo
167160 * local_path = NULL ;
168161 * local_line = -1 ;
169162
170- xdfree (url_path );
171163 return XDEBUG_PATH_MAP_FLAGS_SKIP ;
172164}
173165
@@ -217,22 +209,20 @@ int local_to_remote(xdebug_path_maps *maps, const char *local_path, size_t local
217209{
218210 xdebug_path_mapping * result ;
219211 xdebug_hash * map = maps -> local_to_remote_map ;
220- char * url_path = xdebug_normalize_path_char (local_path );
221212
222- if (!xdebug_hash_find (map , url_path , strlen (url_path ), (void * * ) & result )) {
213+ if (!xdebug_hash_find (map , local_path , strlen (local_path ), (void * * ) & result )) {
223214 /* We can't find an exact file match, so now try to see if we have a directory match, starting with the full
224215 * path and then removing the trailing directory path until there are none left */
225216 char * end_slash ;
226217 char * directory ;
227218
228- end_slash = strrchr ((char * ) url_path , '/' );
219+ end_slash = strrchr ((char * ) local_path , DEFAULT_SLASH );
229220 if (!end_slash ) {
230- xdfree (url_path );
231221 return XDEBUG_PATH_MAP_TYPE_UNKNOWN ;
232222 }
233223
234- directory = xdstrndup (url_path , end_slash - url_path + 1 );
235- end_slash = strrchr ((char * ) directory , '/' );
224+ directory = xdstrndup (local_path , end_slash - local_path + 1 );
225+ end_slash = strrchr ((char * ) directory , DEFAULT_SLASH );
236226
237227 do {
238228 size_t n = end_slash - directory + 1 ;
@@ -242,19 +232,17 @@ int local_to_remote(xdebug_path_maps *maps, const char *local_path, size_t local
242232 * remote_line = local_line ;
243233
244234 * remote_path = xdebug_str_new ();
245- xdebug_str_add_fmt (* remote_path , "%s%s" , result -> remote_path -> d , url_path + n );
235+ xdebug_str_add_fmt (* remote_path , "%s%s" , result -> remote_path -> d , local_path + n );
246236
247237 xdfree (directory );
248- xdfree (url_path );
249238 return XDEBUG_PATH_MAP_TYPE_DIRECTORY ;
250239 }
251240 }
252241
253- end_slash = strrnchr (directory , '/' , n - 1 );
242+ end_slash = strrnchr (directory , DEFAULT_SLASH , n - 1 );
254243 } while (end_slash );
255244
256245 xdfree (directory );
257- xdfree (url_path );
258246 return XDEBUG_PATH_MAP_TYPE_UNKNOWN ;
259247 }
260248
@@ -289,7 +277,6 @@ int local_to_remote(xdebug_path_maps *maps, const char *local_path, size_t local
289277 }
290278 }
291279
292- xdfree (url_path );
293280 return result -> type ;
294281}
295282
0 commit comments