source/buffer_ops.c file

Contents

Functions

auto buffer_is_eq(const uint8_t** current, size_t* remaining, const uint8_t* data, size_t data_size) -> compare_result
A memcmp wrapper to compare current and data until data_size length with bounds checking.
auto read_byte(const uint8_t** current, size_t* remaining, uint8_t* destination) -> bool
Reads an 8 bit number with bounds checking.
auto read_byte_un(const uint8_t** buffer) -> uint8_t
Reads an 8 bit number without bounds checking.
auto read_le_short(const uint8_t** current, size_t* remaining, uint16_t* destination) -> bool
Reads a 16 bit little-endian number with bounds checking.
auto read_le_short_un(const uint8_t** buffer) -> uint16_t
Reads a 16 bit little-endian number without bounds checking.
auto skip_bytes(const uint8_t** current, size_t* remaining, size_t count) -> bool
Skips count number of bytes with bounds checking.
auto read_color_un(const uint8_t** buffer) -> uint32_t
Reads a 3 byte color in the RGB format.
static auto size_to_count(const uint8_t size) -> size_t
auto read_color_table(const uint8_t** current, size_t* remaining, uint32_t** destination, uint8_t size, gif_allocator allocator) -> gif_result_code
Reads a color table.

Function documentation

compare_result buffer_is_eq(const uint8_t** current, size_t* remaining, const uint8_t* data, size_t data_size)

A memcmp wrapper to compare current and data until data_size length with bounds checking.

Returns Result of the equality comparison or an indication of OOB

This function will advance the pointer pointed to by current by data_size if the read isn't OOB.

bool read_byte(const uint8_t** current, size_t* remaining, uint8_t* destination)

Reads an 8 bit number with bounds checking.

Returns true if the read isn't OOB, otherwise false

This function will advance the pointer pointed to by current by 1 if the read isn't OOB.

uint8_t read_byte_un(const uint8_t** buffer)

Reads an 8 bit number without bounds checking.

This function will advance the pointer pointed to by buffer by 1.

bool read_le_short(const uint8_t** current, size_t* remaining, uint16_t* destination)

Reads a 16 bit little-endian number with bounds checking.

Returns true if the read isn't OOB, otherwise false

This function will advance the pointer pointed to by current by 2 if the read isn't OOB.

uint16_t read_le_short_un(const uint8_t** buffer)

Reads a 16 bit little-endian number without bounds checking.

This function will advance the pointer pointed to by buffer by 2.

bool skip_bytes(const uint8_t** current, size_t* remaining, size_t count)

Skips count number of bytes with bounds checking.

This function will advance the pointer pointed to by current by count.

uint32_t read_color_un(const uint8_t** buffer)

Reads a 3 byte color in the RGB format.

Returns 32 bit integer in the 0x00RRGGBB format that encodes an RGB color

This function will advance the pointer pointed to by current by 3.

gif_result_code read_color_table(const uint8_t** current, size_t* remaining, uint32_t** destination, uint8_t size, gif_allocator allocator)

Reads a color table.

This function will advance the pointer pointed to by current by (2 << size) * 3. The allocated color table will be output via the destination parameter.