Changeset 80bee81 in mainline for uspace/lib/c/generic/io/io.c
- Timestamp:
- 2015-09-21T22:40:52Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a955fcc
- Parents:
- 7db5cfd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/io.c
r7db5cfd r80bee81 299 299 } 300 300 301 int fclose(FILE *stream) 301 302 static int _fclose_nofree(FILE *stream) 302 303 { 303 304 int rc = 0; … … 312 313 313 314 list_remove(&stream->link); 315 316 if (rc != 0) { 317 /* errno was set by close() */ 318 return EOF; 319 } 320 321 return 0; 322 } 323 324 int fclose(FILE *stream) 325 { 326 int rc = _fclose_nofree(stream); 314 327 315 328 if ((stream != &stdin_null) … … 318 331 free(stream); 319 332 320 stream = NULL; 321 322 if (rc != 0) { 323 /* errno was set by close() */ 324 return EOF; 325 } 326 327 return 0; 333 return rc; 334 } 335 336 FILE *freopen(const char *path, const char *mode, FILE *stream) 337 { 338 FILE *nstr; 339 340 if (path == NULL) { 341 /* Changing mode is not supported */ 342 return NULL; 343 } 344 345 (void) _fclose_nofree(stream); 346 nstr = fopen(path, mode); 347 if (nstr == NULL) { 348 free(stream); 349 return NULL; 350 } 351 352 list_remove(&nstr->link); 353 *stream = *nstr; 354 list_append(&stream->link, &files); 355 356 free(nstr); 357 358 return stream; 328 359 } 329 360
Note:
See TracChangeset
for help on using the changeset viewer.