Add mozilla::NeverAllocPolicy

RESOLVED FIXED in Firefox 56

Status

()

RESOLVED FIXED
a year ago
a year ago

People

(Reporter: Nika, Assigned: Nika)

Tracking

unspecified
mozilla56
Points:
---

Firefox Tracking Flags

(firefox56 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

a year ago
For some situations, such as in bug 1380096, it's useful to use MFBT types like Vector in situations where it would be Very Bad(tm) to allocate any memory.

For those situations, I suggest we add mozilla::NeverAllocPolicy, which is an alloc policy like MallocAllocPolicy, except it always fails to allocate, returning `nullptr`.
(Assignee)

Comment 1

a year ago
Created attachment 8885833 [details] [diff] [review]
Add NeverAllocPolicy

MozReview-Commit-ID: 8U38Oj3vyaF
Attachment #8885833 - Flags: review?(erahm)

Comment 2

a year ago
Comment on attachment 8885833 [details] [diff] [review]
Add NeverAllocPolicy

Review of attachment 8885833 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM, but we should get a mfbt peer to sign off. Mike this is pretty straightforward and came out of a discussion in another bug, a simplified version of the usage we were talking about would be to replace something like:

> char buffer[kMax];
> size_t used = std::min(str.len, kMax);
> memcpy(buffer, str, used);

with:

> Vector<char, kMax, NeverAllocPolicy> buffer;
> buffer.append(str, used);
Attachment #8885833 - Flags: review?(mh+mozilla)
Attachment #8885833 - Flags: review?(erahm)
Attachment #8885833 - Flags: review+
(Assignee)

Comment 3

a year ago
(In reply to Eric Rahm [:erahm] (please no mozreview requests) from comment #2)
> LGTM, but we should get a mfbt peer to sign off.

Oops. for some reason in my head you were a mfbt peer ^.^.
Attachment #8885833 - Flags: review?(mh+mozilla) → review+

Comment 5

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/0318e26f75c8
Status: NEW → RESOLVED
Last Resolved: a year ago
status-firefox56: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in before you can comment on or make changes to this bug.