src: malloced_unique_ptr & make_malloced_unique#23642
src: malloced_unique_ptr & make_malloced_unique#23642refack wants to merge 1 commit intonodejs:masterfrom
Conversation
IMHO they are only loosely make sense as a pair. They are not used as a pair, and are used in association only in: The cost of pairing them together should be weight against using a non-optimal abstraction to store them together. |
They define the bounds of array together. Semantically, they are a pair.
I’m not sure what you mean by “in association” – they are used together in multiple calls you are modifying here. As for the |
13b0bbf to
a583814
Compare
Yes, but as I read it they are not used together, so the cost of keeping them together outweighs the benefits.
Yeah it's tricky. But I do agree that if that existed it would make sense to use a Buffer-like structure all along. |
It’s better than
What cost are you referring to? There’s zero runtime overhead over having two separate variables, but on the other hand, there’s readability overhead in splitting the struct up. |
fhinkel
left a comment
There was a problem hiding this comment.
I'd rather we document that MallocedBuffer(T* data, size_t size) assumes that data data was allocated with malloc than delete the method.
a583814 to
5bd49eb
Compare
|
Reverted unrelated changes, PTAL. |
Alternative to #23641
malloced_unique_ptris just a specialization ofstd:unique_ptrusingfreefor deletion, andmake_malloced_unique<T>is it's factory usingMalloc<T>.Ref: #23641
Ref: #23543 (review)
Ref: #23434
CI: https://ci.nodejs.org/job/node-test-pull-request/17822/
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes