XZ Utils  5.4.1
Macros | Functions | Variables
memcmplen.h File Reference

Optimized comparison of two buffers. More...

#include "common.h"

Macros

#define LZMA_MEMCMPLEN_EXTRA   0
 

Functions

static uint32_t lzma_attribute ((__always_inline__)) lzma_memcmplen(const uint8_t *buf1
 
 assert (limit<=UINT32_MAX/2)
 
 while (len< limit &&buf1[len]==buf2[len])++len
 

Variables

static uint32_t const uint8_t * buf2
 
static uint32_t const uint8_t uint32_t len
 
static uint32_t const uint8_t uint32_t uint32_t limit
 

Detailed Description

Optimized comparison of two buffers.

Function Documentation

◆ lzma_attribute()

static uint32_t lzma_attribute ( (__always_inline__)  ) const
inlinestatic

Find out how many equal bytes the two buffers have.

Parameters
buf1First buffer
buf2Second buffer
lenHow many bytes have already been compared and will be assumed to match
limitHow many bytes to compare at most, including the already-compared bytes. This must be significantly smaller than UINT32_MAX to avoid integer overflows. Up to LZMA_MEMCMPLEN_EXTRA bytes may be read past the specified limit from both buf1 and buf2.
Returns
Number of equal bytes in the buffers is returned. This is always at least len and at most limit.
Note
LZMA_MEMCMPLEN_EXTRA defines how many extra bytes may be read. It's rounded up to 2^n. This extra amount needs to be allocated in the buffers being used. It needs to be initialized too to keep Valgrind quiet.

Variable Documentation

◆ limit

uint32_t const uint8_t uint32_t uint32_t limit
Initial value:
{
assert(len <= limit)