| 516 | } |
| 517 | } |
| 518 | void LoadHistory(FILE *fIn) |
| 519 | { |
| 520 | AreaLine emptyLine; |
| 521 | |
| 522 | assert(!firstShotU); // We must load snapshots into an empty history |
| 523 | Snapshot *currShot = NULL; |
| 524 | fread(&currShot, sizeof(Snapshot*), 1, fIn); // Load pointer that marks that we have a snapshot |
| 525 | while(currShot) |
| 526 | { |
| 527 | AddSnapshotToList(); // lastShotU points to added snapshot |
| 528 | Snapshot *_nextShot = lastShotU->nextShot, *_prevShot = lastShotU->prevShot; // These two pointers will be corrupted |
| 529 | fread(lastShotU, sizeof(Snapshot), 1, fIn); // Load snapshot |
| 530 | currShot = lastShotU->nextShot; // Pointer marks that we have a next snapshot |
| 531 | lastShotU->nextShot = _nextShot; lastShotU->prevShot = _prevShot; // Restore corrupted pointers |
| 532 | AreaLine *line = lastShotU->first; // Pointer marks that we have a line to load |
| 533 | lastShotU->first = NULL; // Clear snapshot lines, they aren't loaded yet |
| 534 | AreaLine *curr = NULL; // List of loaded lines |
| 535 | while(line) |
| 536 | { |
| 537 | if(data) |
| 538 | curr = InsertLineAfter(curr); // Add new line |
| 539 | else |
| 540 | curr = &emptyLine; |
| 541 | if(!lastShotU->first) |
| 542 | lastShotU->first = curr; // Set line list |
| 543 | fread(curr, sizeof(AreaLine), 1, fIn); // Load line |
| 544 | line = curr->next; // Pointer marks that we have a next line to load |
| 545 | curr->next = NULL; // Clear it, we haven't loaded next line yet |
| 546 | if(curr->maxLength != DEFAULT_STRING_LENGTH) |
| 547 | { |
| 548 | if(data) |
| 549 | { |
| 550 | curr->data = new AreaChar[curr->maxLength]; |
| 551 | fread(curr->data, sizeof(AreaChar), curr->maxLength, fIn); |
| 552 | }else{ |
| 553 | fseek(fIn, sizeof(AreaChar) * curr->maxLength, SEEK_CUR); |
| 554 | } |
| 555 | }else{ |
| 556 | curr->data = curr->startBuf; // Fixup pointer to data |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | void ValidateHistory() |
| 562 | { |
| 563 | Snapshot *curr = firstShotU; |
nothing calls this directly
no test coverage detected