Skip to content
FutureBlitz

    Install

    Import std.ffi.mem

    std.ffi.mem

    Raw memory, which Unsafe code allocates, resizes, fills, copies, compares, and gives back, through the runtime, whose C functions a program can declare as it likes. Sizes are Int64s, as SizeOf's and two Ptrs' difference are, so one that went below 0 panics instead of wrapping around to a huge size.

    std/ffi/mem.fb

    Types

    Mem struct

    Public Struct Mem

    Mem's Static Methods. What Alloc, AllocUninitialized, and Resize give, Free gives back, and what AllocAligned gives, FreeAligned.

    std/ffi/mem.fb, line 20

    • @PanicsAtCaller Public Unsafe Static Method Alloc(bytes: Int64): Ptr<Void> static method #

      bytes of new memory, all 0. Panics when bytes is negative, or there isn't that much.

    • @PanicsAtCaller Public Unsafe Static Method AllocUninitialized(bytes: Int64): Ptr<Void> static method #

      bytes of new memory, as Alloc gives, but not set to 0, so it holds whatever was there, which Unsafe code writes before it reads. Panics when bytes is negative, or there isn't that much.

    • @PanicsAtCaller Public Unsafe Static Method AllocAligned(bytes: Int64, alignment: Int64): Ptr<Void> static method #

      bytes of new memory, all 0, at an address that's a multiple of alignment, a power of two, as SIMD code and some C libraries need. Only FreeAligned gives it back, and Resize doesn't take it. Panics when bytes is negative, alignment isn't a power of two, or there isn't that much.

    • Public Unsafe Static Method FreeAligned(memory: Ptr<Void>) static method #

      Gives back what AllocAligned gave. Null is nothing to give back.

    • @PanicsAtCaller Public Unsafe Static Method Resize(memory: Ptr<Void>, bytes: Int64): Ptr<Void> static method #

      What Alloc, AllocUninitialized, or Resize gave, in bytes of memory, which may have moved: it keeps what fits, and what it adds isn't 0. Null is new memory. Panics when bytes is negative, or there isn't that much.

    • Public Unsafe Static Method Free(memory: Ptr<Void>) static method #

      Gives back what Alloc, AllocUninitialized, or Resize gave. Null is nothing to give back.

    • @PanicsAtCaller Public Unsafe Static Method Copy(destination: Ptr<Void>, source: Ptr<Void>, bytes: Int64) static method #

      Copies bytes from source to destination, which can overlap. Panics when bytes is negative, or when it isn't 0 and either is Null.

    • @PanicsAtCaller Public Unsafe Static Method Fill(destination: Ptr<Void>, value: UInt8, bytes: Int64) static method #

      Sets bytes of memory from destination on to value. Panics when bytes is negative, or when it isn't 0 and destination is Null.

    • @PanicsAtCaller Public Unsafe Static Method Compare(a: Ptr<Void>, b: Ptr<Void>, bytes: Int64): Int32 static method #

      Compares bytes of memory at a with as many at b: 0 when they're the same, or -1 or 1 as the first byte that differs, read as a UInt8, is lower at a or at b. Panics when bytes is negative, or when it isn't 0 and either is Null.

    Report an issue with this page or with FutureBlitz on GitHub.