[Issue 19164] malloc may be considered pure when failure results in program exit (no need to reset errno)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 18 08:25:35 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19164

--- Comment #7 from Nathan S. <n8sh.secondary at hotmail.com> ---
The name "enforceMalloc" was chosen to be similar to "enforce" which throws an
exception if its argument is false. The idea being "enforceMalloc" is like a
shorthand way of writing: "auto ptr = malloc(sz);
enforce!OutOfMemoryError(ptr);"

>If anyone in five years time adds something else to Phobos that uses
>those functions, how are they to know they shouldn't pass 0 to them?

They can know by opening std.internal.memory and looking at what
`enforceMalloc` does. If they don't know then they should not use it!

--


More information about the Digitalmars-d-bugs mailing list