MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / cfclose

Function cfclose

cfile/cfile.cpp:539–562  ·  view source on GitHub ↗

Closes an open CFILE. Parameters: cfile - the file pointer returned by cfopen()

Source from the content-addressed store, hash-verified

537// Closes an open CFILE.
538// Parameters: cfile - the file pointer returned by cfopen()
539void cfclose(CFILE *cfp) {
540 // Either give the file back to the library, or close it
541 if (cfp->lib_handle != -1) {
542 std::shared_ptr<library> lib;
543 for (lib = Libraries; lib; lib = lib->next) {
544 if (lib->handle == cfp->lib_handle) { // found the library
545 // if library doesn't already have a file, give it this one
546 if (lib->file == nullptr) {
547 lib->file = cfp->file;
548 cfp->file = nullptr;
549 }
550 break;
551 }
552 }
553 }
554 // If the file handle wasn't given back to library, close the file
555 if (cfp->file)
556 fclose(cfp->file);
557 // free the name, if allocated
558 if (!cfp->lib_offset)
559 mem_free(cfp->name);
560 // free the cfile struct
561 mem_free(cfp);
562}
563
564// Just like stdio fgetc(), except works on a CFILE
565// Returns a char or EOF

Callers 15

mng_FindSpecificShipPageFunction · 0.85
mng_InitPagelocksFunction · 0.85
mng_CheckIfLockerPresentFunction · 0.85
TableVersionCurrentFunction · 0.85
mng_MakeLockerFunction · 0.85
mng_EraseLockerFunction · 0.85
mng_CheckIfPageLockedFunction · 0.85
mng_CheckIfPageOwnedFunction · 0.85
mng_ReplacePagelockFunction · 0.85
mng_DeletePagelockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected