зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1839396 part 1 - Explicit Sprinter::forwardOutOfMemory(). r=mgaudet
This change move the error reporting to the JSContext to be an independent function, such that we can later migrate `Sprinter::put` to become infallible. Differential Revision: https://phabricator.services.mozilla.com/D181486
This commit is contained in:
Родитель
9a400afd70
Коммит
df269a464c
|
@ -134,6 +134,13 @@ class JS_PUBLIC_API Sprinter final : public GenericPrinter {
|
|||
// first call to this function calls JS_ReportOutOfMemory, and sets this
|
||||
// Sprinter's outOfMemory flag; subsequent calls do nothing.
|
||||
virtual void reportOutOfMemory() override;
|
||||
|
||||
// When an OOM has already been reported on the Sprinter, this function will
|
||||
// forward this error to the JSContext given in the Sprinter initialization.
|
||||
//
|
||||
// If no JSContext had been provided or the Sprinter is configured to not
|
||||
// report OOM, then nothing happens.
|
||||
void forwardOutOfMemory();
|
||||
};
|
||||
|
||||
// Fprinter, print a string directly into a file.
|
||||
|
|
|
@ -223,10 +223,15 @@ void Sprinter::reportOutOfMemory() {
|
|||
if (hadOOM_) {
|
||||
return;
|
||||
}
|
||||
hadOOM_ = true;
|
||||
forwardOutOfMemory();
|
||||
}
|
||||
|
||||
void Sprinter::forwardOutOfMemory() {
|
||||
MOZ_ASSERT(hadOOM_);
|
||||
if (maybeCx && shouldReportOOM) {
|
||||
ReportOutOfMemory(maybeCx);
|
||||
}
|
||||
hadOOM_ = true;
|
||||
}
|
||||
|
||||
bool Sprinter::jsprintf(const char* format, ...) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче