зеркало из https://github.com/mozilla/pjs.git
Bug 497815 - Read Wave headers in small chunks to avoid unnecessary large allocations. r=roc
--HG-- extra : rebase_source : 355af524b6d9f0634d9d09e4ddc1ce1715bc6c81
This commit is contained in:
Родитель
79cbcf1434
Коммит
b128b425c6
|
@ -976,19 +976,23 @@ nsWaveStateMachine::ScanForwardUntil(PRUint32 aWantedChunk, PRUint32* aChunkSize
|
|||
}
|
||||
|
||||
PRUint32 magic = ReadUint32BE(&p);
|
||||
PRUint32 size = ReadUint32LE(&p);
|
||||
PRUint32 chunkSize = ReadUint32LE(&p);
|
||||
|
||||
if (magic == aWantedChunk) {
|
||||
*aChunkSize = size;
|
||||
*aChunkSize = chunkSize;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// RIFF chunks are two-byte aligned, so round up if necessary.
|
||||
size += size % 2;
|
||||
chunkSize += chunkSize % 2;
|
||||
|
||||
nsAutoArrayPtr<char> chunk(new char[size]);
|
||||
if (!ReadAll(chunk.get(), size)) {
|
||||
return PR_FALSE;
|
||||
while (chunkSize > 0) {
|
||||
PRUint32 size = PR_MIN(chunkSize, 1 << 16);
|
||||
nsAutoArrayPtr<char> chunk(new char[size]);
|
||||
if (!ReadAll(chunk.get(), size)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
chunkSize -= size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче