DIP 1025--Dynamic Arrays Only Shrink, Never Grow--Community Review Round 1
newshound2 at digitalmars.com
Tue Nov 12 03:49:57 UTC 2019
On 11/11/2019 7:35 PM, Jab wrote:
> On Tuesday, 12 November 2019 at 03:08:28 UTC, Walter Bright wrote:
>> On 11/11/2019 7:24 AM, jmh530 wrote:
>>> malloc is also only allowed in @system code.
>> Although malloc() is marked as @system, it actually is @safe. It's free() that
>> needs to be @system.
> You can only really consider malloc @safe cause "void*" is completely useless in
> @safe, and casting it to a different type is what is unsafe. By those
> constraints free() could also be considered "safe". If you do cast the pointer
> to another type, then both are not safe.
The cast of the pointer returned from malloc() is indeed unsafe, but the
malloc() call is safe.
More information about the Digitalmars-d