From fa2cffbb246da91e16911c685142a01b7814cff8 Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Sat, 3 Apr 2021 14:38:49 +0200 Subject: [PATCH] Fixed pointer bug --- include/gp/pointers.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/gp/pointers.hpp b/include/gp/pointers.hpp index 92938db..95b5584 100644 --- a/include/gp/pointers.hpp +++ b/include/gp/pointers.hpp @@ -72,8 +72,11 @@ namespace gp { shared_ptr(T* _data, gp::allocator& _owner) : data(_data) + , refcounter((std::atomic_int)owner.allocate(sizeof(std::atomic_int))) , owner(_owner) - {} + { + refcounter->store(1); + } void dirty_clear() { if(!refcounter) return; @@ -89,9 +92,6 @@ namespace gp { template static shared_ptr make(gp::allocator& owner, U&&... args) { auto ptr = owner.allocate(sizeof(T)); - auto shared_atomic = owner.allocate(sizeof(std::atomic_int)); - refcounter = new(shared_atomic) std::atomic_int(); - refcounter->store(1); return shared_ptr(new(ptr) T(gp::forward(args)...), owner); }