void CloseProjDB() { freemem((void**) &inter); freemem((void**) &intra); freemem((void**) &inter_freq_idx); freemem((void**) &intra_freq_idx); CloseMemMap(&pDatasetMemMap); }
int MAPFAM::DeleteRecords(PGLOBAL g, int irc) { int n; if (trace) htrc("MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n", irc, Mempos, To_Buf, Tpos, Spos); if (irc != RC_OK) { /*******************************************************************/ /* EOF: position Fpos at the top of map position. */ /*******************************************************************/ Fpos = Top; if (trace) htrc("Fpos placed at file top=%p\n", Fpos); } // endif irc if (Tpos == Spos) /*******************************************************************/ /* First line to delete. Move of eventual preceding lines is */ /* not required here, just setting of future Spos and Tpos. */ /*******************************************************************/ Tpos = Fpos; // Spos is set below else if ((n = Fpos - Spos) > 0) { /*******************************************************************/ /* Non consecutive line to delete. Move intermediate lines. */ /*******************************************************************/ memmove(Tpos, Spos, n); Tpos += n; if (trace) htrc("move %d bytes\n", n); } // endif n if (irc == RC_OK) { Spos = Mempos; // New start position if (trace) htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos); } else if (To_Fb) { // Can be NULL for deleted files /*******************************************************************/ /* Last call after EOF has been reached. */ /* We must firstly Unmap the view and use the saved file handle */ /* to put an EOF at the end of the copied part of the file. */ /*******************************************************************/ PFBLOCK fp = To_Fb; CloseMemMap(fp->Memory, (size_t)fp->Length); fp->Count = 0; // Avoid doing it twice /*******************************************************************/ /* Remove extra records. */ /*******************************************************************/ n = Tpos - Memory; #if defined(WIN32) DWORD drc = SetFilePointer(fp->Handle, n, NULL, FILE_BEGIN); if (drc == 0xFFFFFFFF) { sprintf(g->Message, MSG(FUNCTION_ERROR), "SetFilePointer", GetLastError()); CloseHandle(fp->Handle); return RC_FX; } // endif if (trace) htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); if (!SetEndOfFile(fp->Handle)) { sprintf(g->Message, MSG(FUNCTION_ERROR), "SetEndOfFile", GetLastError()); CloseHandle(fp->Handle); return RC_FX; } // endif CloseHandle(fp->Handle); #else // UNIX if (ftruncate(fp->Handle, (off_t)n)) { sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno)); close(fp->Handle); return RC_FX; } // endif close(fp->Handle); #endif // UNIX } // endif irc return RC_OK; // All is correct } // end of DeleteRecords