* Close a file returned by AllocateFile. * * Note we do not check fclose's return value --- it is up to the caller * to handle close errors. */
| 2700 | * to handle close errors. |
| 2701 | */ |
| 2702 | int |
| 2703 | FreeFile(FILE *file) |
| 2704 | { |
| 2705 | int i; |
| 2706 | |
| 2707 | DO_DB(elog(LOG, "FreeFile: Allocated %d", numAllocatedDescs)); |
| 2708 | |
| 2709 | /* Remove file from list of allocated files, if it's present */ |
| 2710 | for (i = numAllocatedDescs; --i >= 0;) |
| 2711 | { |
| 2712 | AllocateDesc *desc = &allocatedDescs[i]; |
| 2713 | |
| 2714 | if (desc->kind == AllocateDescFile && desc->desc.file == file) |
| 2715 | return FreeDesc(desc); |
| 2716 | } |
| 2717 | |
| 2718 | /* Only get here if someone passes us a file not in allocatedDescs */ |
| 2719 | elog(WARNING, "file passed to FreeFile was not obtained from AllocateFile"); |
| 2720 | Assert(false); |
| 2721 | |
| 2722 | return fclose(file); |
| 2723 | } |
| 2724 | |
| 2725 | /* |
| 2726 | * Close a file returned by OpenTransientFile. |
no test coverage detected