Project

General

Profile

Actions

Feature #298

open

memory.smartref safety

Added by Eugen Wissner 11 months ago. Updated 8 months ago.

Status:
New
Priority:
Normal
% Done:

0%


Description

RefCounted and Unique give false safity guaranties.

  • Assignment of T to RefCounted!T should be prohibited. RefCounted!T can keep the allocator of the previous object that doesn't match the allocator used to create the new one. Only RefCounted!T can be assigned to RefCounted!T.
  • The constructor that takes an existing object and the allocator should be @system. There is no guarantie that the object was really allocated with the given allocator. refCounted which constructs the object and wraps it into RefCounted can be trusted.
  • For structs and unions the constructor and destructor can only be trusted if the appropriate methods of the struct or union are safe.
  • RefCounted and Unique should know of each other. Unique can be assigned to RefCounted, so RefCounted takes over the ownership of the object. The assignment can be trusted since RefCounted can take the information about destroying the object from Unique.
  • Similar rules apply to Unique.

No data to display

Actions

Also available in: Atom PDF