| 444 | } |
| 445 | |
| 446 | void |
| 447 | bclose(int fd) |
| 448 | { |
| 449 | int idx = getidx(fd, NOSLOT); |
| 450 | |
| 451 | bufoff(fd); /* sets bw_buffered[idx] = 0 */ |
| 452 | if (idx >= 0) { |
| 453 | #ifdef USE_BUFFERING |
| 454 | if (bw_FILE[idx]) { |
| 455 | (void) fclose(bw_FILE[idx]); |
| 456 | bw_FILE[idx] = 0; |
| 457 | } else |
| 458 | #endif |
| 459 | close(fd); |
| 460 | /* return the idx to the pool */ |
| 461 | bw_sticky[idx] = -1; |
| 462 | } |
| 463 | #ifdef SFLOGGING |
| 464 | if (fd >= 0 && fd <= SIZE(ofp)) { |
| 465 | if (ofp[fd]) { |
| 466 | fclose(ofp[fd]); |
| 467 | ofp[fd] = 0; |
| 468 | } else if (ifp[fd]) { |
| 469 | fclose(ifp[fd]); |
| 470 | ifp[fd] = 0; |
| 471 | } |
| 472 | } |
| 473 | #endif |
| 474 | return; |
| 475 | } |
| 476 | |
| 477 | void |
| 478 | bflush(int fd) |