DDraceNetwork Documentation
Loading...
Searching...
No Matches
Bytes

Functions

void swap_endian (void *data, unsigned elem_size, unsigned num)
unsigned bytes_be_to_uint (const unsigned char *bytes)
void uint_to_bytes_be (unsigned char *bytes, unsigned value)

Detailed Description

Byte-manipulation utilities.

Function Documentation

◆ bytes_be_to_uint()

unsigned bytes_be_to_uint ( const unsigned char * bytes)

Packs 4 big endian bytes into an unsigned.

Parameters
bytesPointer to an array of bytes that will be packed.
Returns
The packed unsigned.
Remarks
Assumes the passed array is least 4 bytes in size.
Assumes unsigned is 4 bytes in size.
See also
uint_to_bytes_be

◆ swap_endian()

void swap_endian ( void * data,
unsigned elem_size,
unsigned num )

Swaps the endianness of data. Each element is swapped individually by reversing its bytes.

Parameters
dataPointer to data to be swapped.
elem_sizeSize in bytes of each element.
numNumber of elements.
Remarks
The caller must ensure that the data is at least elem_size * num bytes in size.

◆ uint_to_bytes_be()

void uint_to_bytes_be ( unsigned char * bytes,
unsigned value )

Packs an unsigned into 4 big endian bytes.

Parameters
bytesPointer to an array where the bytes will be stored.
valueThe values that will be packed into the array.
Remarks
Assumes the passed array is least 4 bytes in size.
Assumes unsigned is 4 bytes in size.
See also
bytes_be_to_uint