Quellcode durchsuchen

Fixed pointer bug

channel
Ludovic 'Archivist' Lagouardette vor 3 Jahren
Ursprung
Commit
fa2cffbb24
1 geänderte Dateien mit 4 neuen und 4 gelöschten Zeilen
  1. +4
    -4
      include/gp/pointers.hpp

+ 4
- 4
include/gp/pointers.hpp Datei anzeigen

@ -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<typename ...U>
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<U>(args)...), owner);
}

Laden…
Abbrechen
Speichern