Changeset 3e5c48c9 in mainline
- Timestamp:
- 2011-07-13T20:44:04Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 159100a
- Parents:
- 9be9c4d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/compl.c
r9be9c4d r3e5c48c9 67 67 /** Pointer inside list of directories */ 68 68 const char **path; 69 /** If not @c NULL, should be freed in the end. */ 70 const char **path_list; 69 71 /** Current open directory */ 70 72 DIR *dir; … … 163 165 } 164 166 *cstart += rpath_sep + 1 - prefix; 165 // printf("cstart=%zu\n", *cstart);166 167 free(prefix); 167 168 168 // printf("\ncs->prefix='%s', dirname='%s'\n", cs->prefix, dirname); 169 170 static const char *dlist2[2]; 171 dlist2[0] = dirname; 172 dlist2[1] = NULL; 173 cs->path = dlist2; 174 /* XXX dirname won't be freed */ 169 cs->path_list = malloc(sizeof(char *) * 2); 170 if (cs->path_list == NULL) { 171 retval = ENOMEM; 172 goto error; 173 } 174 cs->path_list[0] = dirname; 175 cs->path_list[1] = NULL; 176 cs->path = cs->path_list; 177 175 178 } else if (cs->is_command) { 176 179 /* Command without path */ … … 193 196 /* Error cleanup */ 194 197 198 if (cs != NULL && cs->path_list != NULL) { 199 size_t i = 0; 200 while (cs->path_list[i] != NULL) { 201 free(cs->path_list[i]); 202 ++i; 203 } 204 free(cs->path_list); 205 } 206 195 207 if (cs != NULL && cs->prefix != NULL) 196 208 free(cs->prefix); … … 271 283 272 284 /* If it was the last one, we are done */ 273 if (cs->dir == NULL) { 274 cs->path = NULL; 285 if (cs->dir == NULL) 275 286 break; 276 }277 287 278 288 /* Read next directory entry */ … … 322 332 compl_t *cs = (compl_t *) state; 323 333 334 if (cs->path_list != NULL) { 335 size_t i = 0; 336 while (cs->path_list[i] != NULL) { 337 free(cs->path_list[i]); 338 ++i; 339 } 340 free(cs->path_list); 341 } 342 324 343 if (cs->last_compl != NULL) 325 344 free(cs->last_compl);
Note:
See TracChangeset
for help on using the changeset viewer.