Typical security issues in C++: why the GC isn't your enemy

Walter Bright newshound2 at digitalmars.com
Mon Jan 23 00:50:24 UTC 2023


I tend to agree with Timon. We've been using the @trusted lambda thing for years 
now, and it just looks like a code smell. For example:

@safe void merry()
{
     @trusted int* p = malloc(10);
     ...
     @trusted free(p);
}

Has this improved anything? I doubt it.

Wouldn't it be far better to encapsulate the malloc/free pair as the allocation 
for an object with certain behaviors, and thus encapsulate the object rather 
than the operations?


More information about the Digitalmars-d mailing list