Skip to content

Make functions which won't cause UB for any input safe #2895

@HKalbasi

Description

@HKalbasi

That is, for example, calling sleep is always fine, with any input, so we can add a #[inline(always)] extern "C" safe wrapper on it, and expose that instead of the original unsafe variant. Similarly, calling malloc on it's own is always ok, only using the result pointer might cause UB, which needs unsafe anyway, so malloc can become safe as well. On the other hand, calling free with bad pointer is UB, so free should remain unsafe.

It helps making unsafe blocks smaller in libc heavy codes, and makes people pay more attention in using really unsafe functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions