MCPcopy Create free account
hub / github.com/catboost/catboost / yfts_close

Function yfts_close

util/folder/fts.cpp:405–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405int yfts_close(FTS* sp)
406{
407 FTSENT *freep, *p;
408 int saved_errno;
409
410 /*
411 * This still works if we haven't read anything -- the dummy structure
412 * points to the root list, so we step through to the end of the root
413 * list which has a valid parent pointer.
414 */
415 if (sp->fts_cur) {
416 for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
417 freep = p;
418 p = p->fts_link ? p->fts_link : p->fts_parent;
419 free(freep);
420 }
421 free(p);
422 }
423
424 /* Free up child linked list, sort array, path buffer. */
425 if (sp->fts_child) {
426 fts_lfree(sp->fts_child);
427 }
428 if (sp->fts_array) {
429 free(sp->fts_array);
430 }
431 free(sp->fts_path);
432
433 /* Return to original directory, save errno if necessary. */
434 if (!ISSET(FTS_NOCHDIR)) {
435 saved_errno = chdir_dird(sp->fts_rfd) ? errno : 0;
436 close_dird(sp->fts_rfd);
437
438 /* Set errno and return. */
439 if (saved_errno != 0) {
440 /* Free up the stream pointer. */
441 free(sp);
442 errno = saved_errno;
443 return (-1);
444 }
445 }
446
447 /* Free up the stream pointer. */
448 free(sp);
449 return (0);
450}
451
452/*
453 * Special case of "/" at the end of the path so that slashes aren't

Callers 2

DestroyMethod · 0.85
~TFileTreeMethod · 0.85

Calls 4

fts_lfreeFunction · 0.85
chdir_dirdFunction · 0.85
close_dirdFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected