[Issue 19164] New: 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
Mon Aug 13 15:01:33 UTC 2018


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

          Issue ID: 19164
           Summary: malloc may be considered pure when failure results in
                    program exit (no need to reset errno)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

A common pattern is to call `core.memory.pureMalloc` and either `assert(false)`
or `onOutOfMemoryError()` if allocation fails. In those places instead using
`malloc` directly (privately annotated as `pure`) would avoid a small amount of
work: the `core.memory.pureMalloc` wrapper reads errno, calls malloc, then
resets errno, which is unnecessary if allocation failure results in the program
exiting at once.

--


More information about the Digitalmars-d-bugs mailing list