You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jasnell@addaleax IINM it would introduce an additional level of indirection to go with std::unique_ptr, because the structure Mmap would have to be heap-allocated and then the void* would be stored within that.
AFAICT std::unique_ptr is good for pointer types that can be freed with FreeThisPointerType(PointerType* ptr); If an additional argument needs to be given to the deleter then that argument, along with the pointer, must be stored in a structure, which becomes heap-allocated if we use std::unique_ptr.
@gabrielschulhof Right, I think this is sometime the Mmap (or let’s be verbose and call it MemoryMapping) class can take of itself in its constructor/destructor. std::unique_ptr or friends don’t really seem to make sense here to me either.
Activity
gabrielschulhof commentedon Mar 29, 2020
@jasnell said
gabrielschulhof commentedon Mar 29, 2020
@jasnell @addaleax IINM it would introduce an additional level of indirection to go with
std::unique_ptr, because the structureMmapwould have to be heap-allocated and then thevoid*would be stored within that.gabrielschulhof commentedon Mar 29, 2020
AFAICT
std::unique_ptris good for pointer types that can be freed withFreeThisPointerType(PointerType* ptr);If an additional argument needs to be given to the deleter then that argument, along with the pointer, must be stored in a structure, which becomes heap-allocated if we usestd::unique_ptr.addaleax commentedon Mar 29, 2020
@gabrielschulhof Right, I think this is sometime the
Mmap(or let’s be verbose and call itMemoryMapping) class can take of itself in its constructor/destructor.std::unique_ptror friends don’t really seem to make sense here to me either.gabrielschulhof commentedon Mar 29, 2020
That's what I was thinking too. A simple class which, in its constructor performs
mmap(2)and its destructor performsmunmap(2).jasnell commentedon Mar 30, 2020
That works for me
src: munmap(2) upon class instance destructor
src: munmap(2) upon class instance destructor
src: munmap(2) upon class instance destructor
src: munmap(2) upon class instance destructor
src: munmap(2) upon class instance destructor