Skip to content

IntToBytesLE

IntToBytesLE

Description

Export an integer into little-endian bytes.

Parameters

Name Direction Description
value in Integer to export
bytes out Destination buffer
max_len in Maximum bytes to write

Usage example (from documentation)

  u64 written = IntToBytesLE(&value, buffer, sizeof(buffer));

Returns

Number of bytes written. Large values are truncated to max_len bytes.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    u64 IntToBytesLE(Int *value, u8 *bytes, u64 max_len) {
        ValidateInt(value);
        u8  out[4]  = {0};
        Int value   = IntFromBytesLE(bytes, sizeof(bytes));
        u64 written = IntToBytesLE(&value, out, sizeof(out));
        Str text    = IntToHexStr(&value);
    
    bool test_int_to_bytes_le_null(void) {
        WriteFmt("Testing IntToBytesLE NULL handling\n");
    
        Int value = IntFrom(1);
    
        Int value = IntFrom(1);
        IntToBytesLE(&value, NULL, 1);
        return false;
    }
Last updated on