Add mozilla::NeverAllocPolicy

RESOLVED FIXED in Firefox 56

Status

()

Core
MFBT
RESOLVED FIXED
5 months ago
5 months ago

People

(Reporter: mystor, Assigned: mystor)

Tracking

unspecified
mozilla56
Points:
---

Firefox Tracking Flags

(firefox56 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 months 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

5 months ago
Created attachment 8885833 [details] [diff] [review]
Add NeverAllocPolicy

MozReview-Commit-ID: 8U38Oj3vyaF
Attachment #8885833 - Flags: review?(erahm)
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

5 months 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 ^.^.

Updated

5 months ago
Attachment #8885833 - Flags: review?(mh+mozilla) → review+

Comment 4

5 months ago
Pushed by michael@thelayzells.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0318e26f75c8
Add NeverAllocPolicy, r=erahm

Comment 5

5 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/0318e26f75c8
Status: NEW → RESOLVED
Last Resolved: 5 months 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.