diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2011-03-18 12:35:56 -0400 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2011-03-18 12:35:56 -0400 |
commit | 815fb65195106b8afe1b8dfec5dae605dbd7ccbe (patch) | |
tree | 44fb495fb8ebe44b54453c3c34d20c14b321bf13 /gpt.cc | |
parent | 5a6085310b7f8fe1c35e56bcab7de161808b488d (diff) | |
download | sgdisk-815fb65195106b8afe1b8dfec5dae605dbd7ccbe.tar.gz |
A few minor changes.
Diffstat (limited to 'gpt.cc')
-rw-r--r-- | gpt.cc | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -1140,6 +1140,7 @@ int GPTData::LoadGPTBackup(const string & filename) { // Let the MBRData class load the saved MBR... protectiveMBR.ReadMBRData(&backupFile, 0); // 0 = don't check block size + protectiveMBR.SetDisk(&myDisk); LoadHeader(&mainHeader, backupFile, 1, &mainCrcOk); @@ -1580,6 +1581,7 @@ int GPTData::SetGPTSize(uint32_t numEntries) { << "partition table size of " << numEntries << "; cannot resize. Perhaps sorting will help.\n"; allOK = 0; + delete[] newParts; } else { // go ahead with copy if (numEntries < numParts) copyNum = numEntries; @@ -2101,12 +2103,17 @@ int GPTData::IsFree(uint64_t sector, uint32_t *partNum) { return (isFree); } // GPTData::IsFree() -// Returns 1 if partNum is unused. +// Returns 1 if partNum is unused AND if it's a legal value. int GPTData::IsFreePartNum(uint32_t partNum) { return ((partNum < numParts) && (partitions != NULL) && (!partitions[partNum].IsUsed())); } // GPTData::IsFreePartNum() +// Returns 1 if partNum is in use. +int GPTData::IsUsedPartNum(uint32_t partNum) { + return ((partNum < numParts) && (partitions != NULL) && + (partitions[partNum].IsUsed())); +} // GPTData::IsUsedPartNum() /*********************************************************** * * @@ -2207,12 +2214,13 @@ bool GPTData::ValidPartNum (const uint32_t partNum) { // functions. const GPTPart & GPTData::operator[](uint32_t partNum) const { if (partNum >= numParts) { - cerr << "Partition number out of range: " << partNum << "\n"; - partNum = 0; - if ((numParts == 0) || (partitions == NULL)) { - cerr << "No partitions defined in GPTData::operator[]; fatal error!\n"; - exit(1); - } // if + cerr << "Partition number out of range (" << partNum << " requested, but only " + << numParts << " available)\n"; + exit(1); + } // if + if (partitions == NULL) { + cerr << "No partitions defined in GPTData::operator[]; fatal error!\n"; + exit(1); } // if return partitions[partNum]; } // operator[] |