0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00

src: separate out NgLibMemoryManagerBase

Extracted from the [QUIC PR](https://github.com/nodejs/node/pull/32379)

So far, this is only used by the QUIC PR directly but the change itself
is independent of QUIC, even if not used directly by anything else yet.
Separated out per request.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/33104
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This commit is contained in:
James M Snell 2020-04-27 13:09:56 -07:00
parent 49db211846
commit 1d69c6f474

View File

@ -13,8 +13,12 @@ namespace mem {
// use different struct names. To allow for code re-use,
// the NgLibMemoryManager template class can be used for both.
struct NgLibMemoryManagerBase {
virtual void StopTrackingMemory(void* ptr) = 0;
};
template <typename Class, typename AllocatorStructName>
class NgLibMemoryManager {
class NgLibMemoryManager : public NgLibMemoryManagerBase {
public:
// Class needs to provide these methods:
// void CheckAllocatedSize(size_t previous_size) const;
@ -24,7 +28,7 @@ class NgLibMemoryManager {
AllocatorStructName MakeAllocator();
void StopTrackingMemory(void* ptr);
void StopTrackingMemory(void* ptr) override;
private:
static void* ReallocImpl(void* ptr, size_t size, void* user_data);