Skip to content

Index

Records

Functions

_clone_tramp1

void _clone_tramp1()

Defined at amd64/clone_tramp1.c#5

app_main

void app_main()

_clone_tramp

void _clone_tramp()

dlrealloc_in_place

void * dlrealloc_in_place(void * , size_t )

realloc_in_place(void* p, size_t n) Resizes the space allocated for p to size n, only if this can be done without moving p (i.e., only if there is adjacent space available if n is greater than p's current allocated size, or n is less than or equal to p's size). This may be used instead of plain realloc if an alternative allocation strategy is needed upon failure to expand space; for example, reallocation of a buffer that must be memory-aligned or cleared. You can use realloc_in_place to trigger these alternatives only when needed.

Returns p if successful; otherwise null.

fmod

double fmod(double a, double b)

Defined at math.c#3

setjmp

int setjmp(jmp_buf buf)

Defined at amd64/setjmp.c#3

stall_read_tsc

static uint64_t stall_read_tsc()

Defined at amd64/stall.c#4

lock

void lock(lock_t * lk)

Defined at lock.c#4

str_to_uint64

uint64_t str_to_uint64(const char * s)

Defined at strconv.c#4

terminal_print

void terminal_print(const char * string, size_t len)

Defined at terminal.c#5

arena_create_chunk

static struct arena_chunk * arena_create_chunk(size_t capacity)

Defined at arena.c#5

amd64_syscall

uintptr_t amd64_syscall(int syscall_num, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6)

Defined at amd64/syscall.c#5

path_basename

const char * path_basename(const char * path)

Defined at path.c#5

date_time_to_unix

uint64_t date_time_to_unix(struct date_time * dt)

Defined at timeutil.c#5

memset

size_t memset(void * dst, uint8_t b, size_t n)

Defined at string.c#6

in_gb_init

void in_gb_init(in_gb_malloc_func_t mallocfn, void * ctx, struct in_gb * gb, size_t capacity)

Defined at in_gb.c#6

fmodf

float fmodf(float a, float b)

Defined at math.c#8

terminal_dimensions

void terminal_dimensions(size_t * cols, size_t * rows)

Defined at terminal.c#10

filereader_init

int filereader_init(struct filereader * fw, const char * path)

Defined at filereader.c#10

dbgcons_print

int dbgcons_print(const char * string, size_t len)

Defined at dbgcons.c#11

premain_memset

static size_t premain_memset(void * dst, uint8_t b, size_t n)

Defined at __premain.c#11

stall_get_tsc_freq_hz

static uint64_t stall_get_tsc_freq_hz()

Defined at amd64/stall.c#11

filewriter_init

int filewriter_init(struct filewriter * fw, const char * path, uint32_t flags)

Defined at filewriter.c#11

quit

int quit()

Defined at system.c#12

unlock

void unlock(lock_t * lk)

Defined at lock.c#13

ceil

double ceil(double x)

Defined at math.c#13

mprintf

void mprintf(const char * fmt)

Defined at mprintf.c#13

cmdline_parse_opt

static void cmdline_parse_opt(const char * cmdline, struct cmdline_opt * opt)

Defined at cmdline_parser.c#13

in_wmalloc

static void * in_wmalloc(void * ctx, size_t size)

Defined at in_input.c#15

memcpy

void * memcpy(void * dst, const void * src, size_t n)

Defined at string.c#15

debug_printf

void debug_printf(const char * fmt)

Defined at dbgcons.c#16

test

int test(char c)

Defined at system.c#17

arena_destroy_chunk

static void arena_destroy_chunk(struct arena_chunk * chunk)

Defined at arena.c#19

in_gb_fini

void in_gb_fini(in_gb_free_func_t freefn, void * ctx, struct in_gb * gb)

Defined at in_gb.c#19

longjmp

void longjmp(jmp_buf buf, int ret)

Defined at amd64/setjmp.c#19

process_spawn

struct process_data * process_spawn(process_func_t func, void * argument_ptr)

Defined at process.c#19

str_to_double

double str_to_double(const char * nptr, char ** endptr)

Defined at strconv.c#19

clear_bss

static void clear_bss()

Defined at __premain.c#20

in_wfree

static void in_wfree(void * ctx, void * mem)

Defined at in_input.c#21

sched

int sched()

Defined at system.c#22

stall_ms

void stall_ms(uint64_t ms)

Defined at amd64/stall.c#22

arena_reset

void arena_reset(struct arena * arena)

Defined at arena.c#24

__premain

void __premain()

Defined at __premain.c#25

in_gb_grow

void in_gb_grow(in_gb_realloc_func_t reallocfn, void * ctx, struct in_gb * gb)

Defined at in_gb.c#25

strncpy

void strncpy(char * dst, const char * src, size_t n)

Defined at string.c#26

SOURCE: https://stackoverflow.com/a/48967408

map

void * map(uintptr_t vaddr, size_t pages, uint32_t flags)

Defined at system.c#27

in_wrealloc

static void * in_wrealloc(void * ctx, void * mem, size_t old, size_t new)

Defined at in_input.c#27

fabs

double fabs(double x)

Defined at math.c#29

filereader_fini

int filereader_fini(struct filereader * fw)

Defined at filereader.c#31

unmap

int unmap(uintptr_t vaddr, size_t pages)

Defined at system.c#32

strlen

size_t strlen(const char * str)

Defined at string.c#33

arena_destroy

void arena_destroy(struct arena * arena)

Defined at arena.c#33

floor

double floor(double x)

Defined at math.c#34

clone

int clone(uintptr_t vstack_top, void ()(void) entry, void * argument_ptr)*

Defined at system.c#37

filereader_read

int filereader_read(struct filereader * fw, uint8_t * buffer, size_t buffer_size)

Defined at filereader.c#37

in_stream_read_line

void in_stream_read_line(const char * prompt, char * buffer, size_t max)

Defined at in_input.c#38

memcmp

int memcmp(const void * s1, const void * s2, size_t n)

Defined at string.c#41

mutex_create

int mutex_create()

Defined at system.c#42

_init_lock

static int _init_lock(lock_t * lk)

Defined at _malloc_port.c#45

sqrt

double sqrt(double x)

Defined at math.c#45

in_gb_move

void in_gb_move(struct in_gb * gb, size_t pos)

Defined at in_gb.c#46

mutex_delete

int mutex_delete(int mutex_rid)

Defined at system.c#47

arena_malloc

void * arena_malloc(struct arena * arena, size_t size)

Defined at arena.c#47

filewriter_fini

int filewriter_fini(struct filewriter * fw)

Defined at filewriter.c#48

process_data_free

void process_data_free(struct process_data * pdata)

Defined at process.c#49

_fini_lock

static int _fini_lock(lock_t * lk)

Defined at _malloc_port.c#51

mutex_lock

int mutex_lock(int mutex_rid)

Defined at system.c#52

filewriter_write

int filewriter_write(struct filewriter * fw, uint8_t * buffer, size_t buffer_size)

Defined at filewriter.c#54

process_self_init

void process_self_init()

Defined at process.c#55

strtokenize

void strtokenize(const char * str, char delim, void * ctx, strtokenize_cb_func_t cb)

Defined at string.c#55

_acquire_lock

static int _acquire_lock(lock_t * lk)

Defined at _malloc_port.c#56

mutex_unlock

int mutex_unlock(int mutex_rid)

Defined at system.c#57

exp

double exp(double x)

Defined at math.c#58

argument_ptr

void * argument_ptr()

Defined at system.c#62

_release_lock

static int _release_lock(lock_t * lk)

Defined at _malloc_port.c#62

process_get_exec_pid

int process_get_exec_pid()

Defined at process.c#63

in_gb_insert

void in_gb_insert(in_gb_realloc_func_t reallocfn, void * ctx, struct in_gb * gb, char c)

Defined at in_gb.c#64

exec

int exec(const char * path, const char * cmdline)

Defined at system.c#67

process_get_exec_pgid

int process_get_exec_pgid()

Defined at process.c#68

read_file

int read_file(const char * path, size_t off, uint8_t * buffer, size_t size)

Defined at system.c#72

process_get_pid

int process_get_pid()

Defined at process.c#73

in_gb_backspace

void in_gb_backspace(struct in_gb * gb)

Defined at in_gb.c#73

log

double log(double x)

Defined at math.c#76

describe

int describe(const char * path, struct desc * desc)

Defined at system.c#77

str_split_lines

void str_split_lines(const char * str, size_t total_len, void * ctx, strtokenize_cb_func_t cb)

Defined at string.c#77

process_get_pgid

int process_get_pgid()

Defined at process.c#78

_open_dummy

int _open_dummy(const char * path, uint16_t modes)

Defined at _malloc_port.c#78

in_gb_length

size_t in_gb_length(struct in_gb * gb)

Defined at in_gb.c#79

get_procgroup

int get_procgroup(int pid)

Defined at system.c#82

mmap

void * mmap(void * addr, size_t size, int prot, int flags, int fd, size_t off)

Defined at _malloc_port.c#84

in_gb_string_at

char * in_gb_string_at(in_gb_malloc_func_t mallocfn, void * ctx, struct in_gb * gb, size_t pos)

Defined at in_gb.c#84

get_exec_pid

int get_exec_pid()

Defined at system.c#87

arena_realloc

void * arena_realloc(struct arena * arena, void * memory, size_t prev_size, size_t new_size)

Defined at arena.c#87

process_write_proc

static void process_write_proc(void * arg)

Defined at process.c#89

read_dir_entry

int read_dir_entry(const char * path, struct dir_entry * entry, size_t entry_num)

Defined at system.c#92

normalize_angle

static double normalize_angle(double x)

Defined at math.c#93

create_file

int create_file(const char * path)

Defined at system.c#97

LZ4F_calloc

static void * LZ4F_calloc(size_t s, LZ4F_CustomMem cmem)

Defined at lz4frame.c#98

munmap

int munmap(void * addr, size_t length)

Defined at _malloc_port.c#101

LZ4HC_getCLevelParams

static cParams_t LZ4HC_getCLevelParams(int cLevel)

Defined at lz4hc.c#101

write_file

int write_file(const char * path, size_t off, uint8_t * buffer, size_t size, uint32_t flags)

Defined at system.c#102

sin

double sin(double x)

Defined at math.c#102

wait_for_pid

int wait_for_pid(int pid)

Defined at system.c#107

process_collect_proc

static void process_collect_proc(void * arg)

Defined at process.c#108

cmdline_parse

int cmdline_parse(const char * cmdline, struct cmdline_opt * opt_array)

Defined at cmdline_parser.c#109

memchr

void * memchr(const void * s, unsigned char c, size_t n)

Defined at string.c#110

https://svnweb.freebsd.org/base/stable/7/lib/libc/string/memchr.c?view=markup

kill

int kill(int pid)

Defined at system.c#112

XXH_malloc

static void * XXH_malloc(size_t s)

Defined at xxhash.c#112

LZ4HC_hashPtr

static U32 LZ4HC_hashPtr(const void * ptr)

Defined at lz4hc.c#114

XXH_free

static void XXH_free(void * p)

Defined at xxhash.c#116

cos

double cos(double x)

Defined at math.c#116

create_dir

int create_dir(const char * path)

Defined at system.c#117

LZ4F_malloc

static void * LZ4F_malloc(size_t s, LZ4F_CustomMem cmem)

Defined at lz4frame.c#117

remove

int remove(const char * path)

Defined at system.c#122

XXH_memcpy

static void * XXH_memcpy(void * dest, const void * src, size_t size)

Defined at xxhash.c#122

tan

double tan(double x)

Defined at math.c#123

strcmp

int strcmp(const char * s1, const char * s2)

Defined at string.c#124

https://stackoverflow.com/a/34873406

in_gb_concat

void in_gb_concat(in_gb_realloc_func_t reallocfn, void * ctx, struct in_gb * dest, struct in_gb * src)

Defined at in_gb.c#124

create_volume

int create_volume(const char * name, int fs_type, const char * device_name)

Defined at system.c#127

LZ4F_free

static void LZ4F_free(void * p, LZ4F_CustomMem cmem)

Defined at lz4frame.c#127

LZ4_read64

static U64 LZ4_read64(const void * ptr)

Defined at lz4hc.c#129

process_spawn_external

int process_spawn_external(const char * path, const char * cmdline)

Defined at process.c#130

atan

double atan(double x)

Defined at math.c#131

exec_partial

int exec_partial(const char * path, const char * cmdline)

Defined at system.c#132

strcat

char * strcat(char * dest, const char * src)

Defined at string.c#134

https://stackoverflow.com/a/2490637

fat_translate

static void fat_translate(size_t fs_block, size_t fs_block_count, size_t fs_block_size, size_t device_sector_size, size_t * out_phys_sector, size_t * out_sector_count)

Defined at fat.c#136

exec_partial_fini

int exec_partial_fini(int pid)

Defined at system.c#137

cmdline_print_help

void cmdline_print_help(struct cmdline_opt * opt_array)

Defined at cmdline_parser.c#138

get_self_pid

int get_self_pid()

Defined at system.c#142

stream_write

int stream_write(int pgid, int rid, void * buffer, size_t size)

Defined at system.c#147

strncmp

int strncmp(const char * s1, const char * s2, size_t n)

Defined at string.c#147

LZ4MID_hash4

static U32 LZ4MID_hash4(U32 v)

Defined at lz4hc.c#148

fat_read

static _Bool fat_read(struct fat32fs_ctx * ctx, uint8_t * buf, uint32_t sector)

Defined at fat.c#148

LZ4MID_hash4Ptr

static U32 LZ4MID_hash4Ptr(const void * ptr)

Defined at lz4hc.c#152

stream_read

int stream_read(int rid, void * buffer, size_t size)

Defined at system.c#152

date_time

int date_time(struct date_time * dt)

Defined at system.c#157

atan2

double atan2(double y, double x)

Defined at math.c#157

LZ4MID_hash7

static U32 LZ4MID_hash7(U64 v)

Defined at lz4hc.c#158

note: hash7 hashes the lower 56-bits. It presumes input was read using little endian.

get_cmdline

const char * get_cmdline()

Defined at system.c#162

fat_write

static _Bool fat_write(struct fat32fs_ctx * ctx, const uint8_t * buf, uint32_t sector)

Defined at fat.c#162

strstr

char * strstr(const char * str, const char * substring)

Defined at string.c#162

https://stackoverflow.com/questions/49131175/recreate-the-strstr-function

LZ4MID_hash8Ptr

static U32 LZ4MID_hash8Ptr(const void * ptr)

Defined at lz4hc.c#164

set_priority

int set_priority(int prio)

Defined at system.c#167

LZ4_readLE64

static U64 LZ4_readLE64(const void * memPtr)

Defined at lz4hc.c#169

get_priority

int get_priority()

Defined at system.c#172

asin

double asin(double x)

Defined at math.c#174

zero_sectors

static _Bool zero_sectors(struct fat32fs_ctx * ctx, uint32_t first, uint32_t count)

Defined at fat.c#176

ioctl2

int ioctl2(const char * path, int cmd, void * a1, void * a2, void * a3, void * a4)

Defined at system.c#177

acos

double acos(double x)

Defined at math.c#185

LZ4HC_NbCommonBytes32

static unsigned int LZ4HC_NbCommonBytes32(U32 val)

Defined at lz4hc.c#188

=== Count match length ===

pow

double pow(double base, double exp1)

Defined at math.c#192

XXH_read32

static U32 XXH_read32(const void * memPtr)

Defined at xxhash.c#194

portable and safe solution. Generally efficient. see : http://stackoverflow.com/a/32095106/646947

strchr

char * strchr(const char * s, int c)

Defined at string.c#194

https://github.com/gcc-mirror/gcc/blob/master/libiberty/strchr.c

LZ4F_readLE32

static U32 LZ4F_readLE32(const void * src)

Defined at lz4frame.c#195

unoptimized version; solves endianness & alignment issues

to_upper

static char to_upper(char c)

Defined at fat.c#199


subpath_len

static int subpath_len(const char * path)

Defined at fat.c#205


LZ4F_writeLE32

static void LZ4F_writeLE32(void * dst, U32 value32)

Defined at lz4frame.c#205

strrchr

char * strrchr(const char * s, int c)

Defined at string.c#205

https://github.com/gcc-mirror/gcc/blob/master/libiberty/strrchr.c

LZ4F_readLE64

static U64 LZ4F_readLE64(const void * src)

Defined at lz4frame.c#214

last_subpath_len

static int last_subpath_len(const char * path)

Defined at fat.c#214


memmove

void * memmove(void * dest, const void * src, unsigned int n)

Defined at string.c#217

SOURCE: https://aticleworld.com/memmove-function-implementation-in-c/

XXH_swap32

static U32 XXH_swap32(U32 x)

Defined at xxhash.c#222

LZ4HC_countBack

static int LZ4HC_countBack(const BYTE const ip, const BYTE const match, const BYTE const iMin, const BYTE const mMin)

Defined at lz4hc.c#224

LZ4HC_countBack() :

return : negative value, nb of common bytes before ip/match

LZ4F_writeLE64

static void LZ4F_writeLE64(void * dst, U64 value64)

Defined at lz4frame.c#228

get_crc

static uint8_t get_crc(const uint8_t * name)

Defined at fat.c#230


XXH_isLittleEndian

static int XXH_isLittleEndian()

Defined at xxhash.c#238

strncat

char * strncat(char * dest, const char * src, size_t n)

Defined at string.c#238

decode_timestamp

static void decode_timestamp(uint16_t date, uint16_t time, Timestamp * ts)

Defined at fat.c#239


encode_timestamp

static void encode_timestamp(uint16_t * date, uint16_t * time)

Defined at fat.c#250


strcpy

char * strcpy(char * strDest, const char * strSrc)

Defined at string.c#254

https://stackoverflow.com/questions/14476627/strcpy-implementation-in-c

XXH_readLE32_align

static U32 XXH_readLE32_align(const void * ptr, XXH_endianness endian, XXH_alignment align)

Defined at xxhash.c#254

LZ4HC_clearTables

static void LZ4HC_clearTables(LZ4HC_CCtx_internal * hc4)

Defined at lz4hc.c#257

***** Init*****

sect_to_clust

static uint32_t sect_to_clust(Fat * fat, uint32_t sect)

Defined at fat.c#260


isalnum

int isalnum(int c)

Defined at string.c#262

XXH_readLE32

static U32 XXH_readLE32(const void * ptr, XXH_endianness endian)

Defined at xxhash.c#262

LZ4HC_init_internal

static void LZ4HC_init_internal(LZ4HC_CCtx_internal * hc4, const BYTE * start)

Defined at lz4hc.c#263

clust_to_sect

static uint32_t clust_to_sect(Fat * fat, uint32_t clust)

Defined at fat.c#266


isalpha

int isalpha(int c)

Defined at string.c#267

XXH_readBE32

static U32 XXH_readBE32(const void * ptr)

Defined at xxhash.c#267

iscntrl

int iscntrl(int c)

Defined at string.c#272

sync_buf

static int sync_buf(struct fat32fs_ctx * ctx, Fat * fat)

Defined at fat.c#272


isdigit

int isdigit(int c)

Defined at string.c#277

LZ4_XXH_versionNumber

unsigned int LZ4_XXH_versionNumber()

Defined at xxhash.c#279

isgraph

int isgraph(int c)

Defined at string.c#282

update_buf

static int update_buf(struct fat32fs_ctx * ctx, Fat * fat, uint32_t sect)

Defined at fat.c#284


islower

int islower(int c)

Defined at string.c#287

isprint

int isprint(int c)

Defined at string.c#292

XXH32_round

static U32 XXH32_round(U32 seed, U32 input)

Defined at xxhash.c#293

LZ4F_isError

unsigned int LZ4F_isError(LZ4F_errorCode_t code)

Defined at lz4frame.c#296

ispunct

int ispunct(int c)

Defined at string.c#297

LZ4F_getErrorName

const char * LZ4F_getErrorName(LZ4F_errorCode_t code)

Defined at lz4frame.c#301

sync_fs

static int sync_fs(struct fat32fs_ctx * ctx, Fat * fat)

Defined at fat.c#301


isspace

int isspace(int c)

Defined at string.c#302

XXH32_avalanche

static U32 XXH32_avalanche(U32 h32)

Defined at xxhash.c#302

mix all bits

isupper

int isupper(int c)

Defined at string.c#307

LZ4_isAligned

static int LZ4_isAligned(const void * ptr, size_t alignment)

Defined at lz4.c#308

isxdigit

int isxdigit(int c)

Defined at string.c#312

LZ4HC_encodeSequence

static int LZ4HC_encodeSequence(const BYTE ** _ip, BYTE ** _op, const BYTE ** _anchor, int matchLength, int offset, limitedOutput_directive limit, BYTE * oend)

Defined at lz4hc.c#312

LZ4HC_encodeSequence() :

return : 0 if ok, 1 if buffer issue detected

XXH32_finalize

static U32 XXH32_finalize(U32 h32, const void * ptr, size_t len, XXH_endianness endian, XXH_alignment align)

Defined at xxhash.c#314

LZ4F_returnErrorCode

static LZ4F_errorCode_t LZ4F_returnErrorCode(LZ4F_errorCodes code)

Defined at lz4frame.c#316

isascii

int isascii(int c)

Defined at string.c#317

isblank

int isblank(int c)

Defined at string.c#322

tolower

int tolower(int chr)

Defined at string.c#327

get_fat

static int get_fat(struct fat32fs_ctx * ctx, Fat * fat, uint32_t clust, uint32_t * out_val, uint8_t * out_flags)

Defined at fat.c#328


toupper

int toupper(int chr)

Defined at string.c#332

get_bit_access

static floating_point_with_bit_access get_bit_access(floating_point_t x)

Defined at printf.c#342

This is unnecessary in C99, since compound initializers can be used, but: 1. Some compilers are finicky about this; 2. Some people may want to convert this to C89; 3. If you try to use it as C++, only C++20 supports compound literals

LZ4F_compressionLevel_max

int LZ4F_compressionLevel_max()

Defined at lz4frame.c#344

LZ4F_compressionLevel_max() :

return maximum allowed compression level (currently: 12)

get_sign_bit

static int get_sign_bit(floating_point_t x)

Defined at printf.c#349

get_exp2

static int get_exp2(floating_point_with_bit_access x)

Defined at printf.c#355

put_fat2

static int put_fat2(struct fat32fs_ctx * ctx, Fat * fat, uint32_t fat_sect, uint32_t clust, uint32_t val)

Defined at fat.c#360


LZ4F_headerChecksum

static BYTE LZ4F_headerChecksum(const void * header, size_t length)

Defined at lz4frame.c#368

LZ4_isLittleEndian

static unsigned int LZ4_isLittleEndian()

Defined at lz4.c#373

LZ4F_optimalBSID

static LZ4F_blockSizeID_t LZ4F_optimalBSID(const LZ4F_blockSizeID_t requestedBSID, const size_t srcSize)

Defined at lz4frame.c#377

-***** Simple-pass compression functions*****

put_fat

static int put_fat(struct fat32fs_ctx * ctx, Fat * fat, uint32_t clust, uint32_t val)

Defined at fat.c#378


XXH32_endian_align

static U32 XXH32_endian_align(const void * input, size_t len, U32 seed, XXH_endianness endian, XXH_alignment align)

Defined at xxhash.c#389

remove_chain

static int remove_chain(struct fat32fs_ctx * ctx, Fat * fat, uint32_t clust)

Defined at fat.c#391


LZ4F_compressBound_internal

static size_t LZ4F_compressBound_internal(size_t srcSize, const LZ4F_preferences_t * preferencesPtr, size_t alreadyBuffered)

Defined at lz4frame.c#398

LZ4F_compressBound_internal() : Provides dstCapacity given a srcSize to guarantee operation success in worst case situations. prefsPtr is optional : if NULL is provided, preferences will be set to cover worst case scenario.

return is always the same for a srcSize and prefsPtr, so it can be relied upon to size reusable buffers. When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() operations.

putchar_via_gadget

static void putchar_via_gadget(output_gadget_t * gadget, char c)

Defined at printf.c#403

Note: This function currently assumes it is not passed a '\0' c, or alternatively, that '\0' can be passed to the function in the output gadget. The former assumption holds within the printf library. It also assumes that the output gadget has been properly initialized.

LZ4HC_searchExtDict

static LZ4HC_match_t LZ4HC_searchExtDict(const BYTE * ip, U32 ipIndex, const BYTE const iLowLimit, const BYTE const iHighLimit, const LZ4HC_CCtx_internal * dictCtx, U32 gDictEndIndex, int currentBestML, int nbAttempts)

Defined at lz4hc.c#412

stretch_chain

static int stretch_chain(struct fat32fs_ctx * ctx, Fat * fat, uint32_t clust, uint32_t * out_clust)

Defined at fat.c#421


LZ4_read16

static U16 LZ4_read16(const void * ptr)

Defined at lz4.c#422

LZ4_read32

static U32 LZ4_read32(const void * ptr)

Defined at lz4.c#426

append_termination_with_gadget

static void append_termination_with_gadget(output_gadget_t * gadget)

Defined at printf.c#427

Possibly-write the string-terminating '\0' character

LZ4_read_ARCH

static reg_t LZ4_read_ARCH(const void * ptr)

Defined at lz4.c#430

LZ4_XXH32

XXH32_hash_t LZ4_XXH32(const void * input, size_t length, unsigned int seed)

Defined at xxhash.c#431

XXH32() : Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input". The memory between input & input+length must be valid (allocated and read-accessible). "seed" can be used to alter the result predictably. Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s

LZ4_write16

static void LZ4_write16(void * memPtr, U16 value)

Defined at lz4.c#435

LZ4_write32

static void LZ4_write32(void * memPtr, U32 value)

Defined at lz4.c#439

putchar_wrapper

static void putchar_wrapper(char c, void * unused)

Defined at printf.c#444

We can't use putchar_ as is, since our output gadget only takes pointers to functions with an extra argument

discarding_gadget

static output_gadget_t discarding_gadget()

Defined at printf.c#450

LZ4_XXH32_createState

XXH32_state_t * LZ4_XXH32_createState()

Defined at xxhash.c#460

====== Hash streaming ======

buffer_gadget

static output_gadget_t buffer_gadget(char * buffer, size_t buffer_size)

Defined at printf.c#461

LZ4MID_searchHCDict

static LZ4HC_match_t LZ4MID_searchHCDict(const BYTE * ip, U32 ipIndex, const BYTE const iHighLimit, const LZ4HC_CCtx_internal * dictCtx, U32 gDictEndIndex)*

Defined at lz4hc.c#464

LZ4_XXH32_freeState

XXH_errorcode LZ4_XXH32_freeState(XXH32_state_t * statePtr)

Defined at xxhash.c#464

LZ4_XXH32_copyState

void LZ4_XXH32_copyState(XXH32_state_t * dst_state, const XXH32_state_t * src_state)

Defined at xxhash.c#470

LZ4F_compressFrameBound

size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t * preferencesPtr)

Defined at lz4frame.c#428

LZ4F_compressFrameBound() : Returns the maximum possible compressed size with LZ4F_compressFrame() given srcSize and preferences. preferencesPtr is optional. It can be replaced by NULL, in which case, the function will assume default preferences. Note : this result is only usable with LZ4F_compressFrame(). It may also be relevant to LZ4F_compressUpdate() only if no flush() operation is ever performed.

LZ4MID_searchExtDict

static LZ4HC_match_t LZ4MID_searchExtDict(const BYTE * ip, U32 ipIndex, const BYTE const iHighLimit, const LZ4HC_CCtx_internal * dictCtx, U32 gDictEndIndex)*

Defined at lz4hc.c#470

function_gadget

static output_gadget_t function_gadget(void ()(char, void ) function, void * extra_arg)

Defined at printf.c#474

LZ4_XXH32_reset

XXH_errorcode LZ4_XXH32_reset(XXH32_state_t * statePtr, unsigned int seed)

Defined at xxhash.c#475

LZ4_readLE16

static U16 LZ4_readLE16(const void * memPtr)

Defined at lz4.c#479

create_chain

static int create_chain(struct fat32fs_ctx * ctx, Fat * fat, uint32_t * out_clust)

Defined at fat.c#482


extern_putchar_gadget

static output_gadget_t extern_putchar_gadget()

Defined at printf.c#483

clust_clear

static int clust_clear(struct fat32fs_ctx * ctx, Fat * fat, uint32_t clust)

Defined at fat.c#488


XXH32_update_endian

static XXH_errorcode XXH32_update_endian(XXH32_state_t * state, const void * input, size_t len, XXH_endianness endian)

Defined at xxhash.c#489

strnlen_s_

static printf_size_t strnlen_s_(const char * str, printf_size_t maxsize)

Defined at printf.c#495

internal secure strlen

return The length of the string (excluding the terminating 0) limited by 'maxsize'

note strlen uses size_t, but wes only use this function with printf_size_t variables - hence the signature.

LZ4_writeLE16

static void LZ4_writeLE16(void * memPtr, U16 value)

Defined at lz4.c#501

is_digit_

static Bool is_digit(char ch)

Defined at printf.c#507

internal test if char is a digit (0-9)

return true if char is a digit

dir_at_clust

static void dir_at_clust(Dir * dir, uint32_t clust)

Defined at fat.c#510


atou_

static printf_size_t atou_(const char ** str)

Defined at printf.c#513

internal ASCII string to printf_size_t conversion

LZ4_wildCopy8

static void LZ4_wildCopy8(void * dstPtr, const void * srcPtr, void * dstEnd)

Defined at lz4.c#513

customized variant of memcpy, which can overwrite up to 8 bytes beyond dstEnd

LZ4_XXH32_update

XXH_errorcode LZ4_XXH32_update(XXH32_state_t * statePtr, const void * input, size_t length)

Defined at xxhash.c#560

LZ4F_compressFrame

size_t LZ4F_compressFrame(void * dstBuffer, size_t dstCapacity, const void * srcBuffer, size_t srcSize, const LZ4F_preferences_t * preferencesPtr)

Defined at lz4frame.c#516

LZ4F_compressFrame() : Compress an entire srcBuffer into a valid LZ4 frame, in a single step. dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). The LZ4F_preferences_t structure is optional : you can provide NULL as argument. All preferences will be set to default.

return : number of bytes written into dstBuffer. or an error code if it fails (can be tested using LZ4F_isError())

LZ4F_compressFrame() : Compress srcBuffer content into an LZ4-compressed frame. It's a one shot operation, all input content is consumed, and all output is generated.

Note : it's a stateless operation (no LZ4F_cctx state needed). In order to reduce load on the allocator, LZ4F_compressFrame(), by default, uses the stack to allocate space for the compression state and some table. If this usage of the stack is too much for your application, consider compiling lz4frame.c with compile-time macro LZ4F_HEAPMODE set to 1 instead. All state allocations will use the Heap. It also means each invocation of LZ4F_compressFrame() will trigger several internal alloc/free invocations.

MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). is optional : one can provide NULL, in which case all preferences are set to default.

return : number of bytes written into dstBuffer. or an error code if it fails (can be tested using LZ4F_isError())

dir_enter

static void dir_enter(Dir * dir, uint32_t clust)

Defined at fat.c#518


out_rev_

static void out_rev_(output_gadget_t * output, const char * buf, printf_size_t len, printf_size_t width, printf_flags_t flags)

Defined at printf.c#523

output the specified string in reverse, taking care of any zero-padding

LZ4MID_addPosition

static void LZ4MID_addPosition(U32 * hTable, U32 hValue, U32 index)

Defined at lz4hc.c#528

***** Mid Compression (level 2)*****

dir_next

static int dir_next(struct fat32fs_ctx * ctx, Dir * dir)

Defined at fat.c#529


LZ4MID_fillHTable

static void LZ4MID_fillHTable(LZ4HC_CCtx_internal * cctx, const void * dict, size_t size)

Defined at lz4hc.c#538

Fill hash tables with references into dictionary. The resulting table is only exploitable by LZ4MID (level 2)

LZ4_memcpy_using_offset_base

static void LZ4_memcpy_using_offset_base(BYTE * dstPtr, const BYTE * srcPtr, BYTE * dstEnd, const size_t offset)

Defined at lz4.c#542

static void print_integer_finalization(output_gadget_t * output, char * buf, printf_size_t len, _Bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags)

Defined at printf.c#554

Invoked by print_integer after the actual number has been printed, performing necessary work on the number's prefix (as the number is initially printed in reverse order)

dir_advance

static int dir_advance(struct fat32fs_ctx * ctx, Dir * dir, int cnt)

Defined at fat.c#560


select_searchDict_function

static LZ4MID_searchIntoDict_f select_searchDict_function(const LZ4HC_CCtx_internal * dictCtx)

Defined at lz4hc.c#564

LZ4_wildCopy32

static void LZ4_wildCopy32(void * dstPtr, const void * srcPtr, void * dstEnd)

Defined at lz4.c#567

customized variant of memcpy, which can overwrite up to 32 bytes beyond dstEnd this version copies two times 16 bytes (instead of one time 32 bytes) because it must be compatible with offsets >= 16.

XXH32_digest_endian

static U32 XXH32_digest_endian(const XXH32_state_t * state, XXH_endianness endian)

Defined at xxhash.c#570

dir_next_stretch

static int dir_next_stretch(struct fat32fs_ctx * ctx, Dir * dir)

Defined at fat.c#571


LZ4MID_compress

static int LZ4MID_compress(LZ4HC_CCtx_internal const ctx, const char const src, char const dst, int * srcSizePtr, const int maxOutputSize, const limitedOutput_directive limit, const dictCtx_directive dict)*

Defined at lz4hc.c#579

preconditions: - *srcSizePtr within [1, LZ4_MAX_INPUT_SIZE] - src is valid - maxOutputSize >= 1 - dst is valid

LZ4_memcpy_using_offset

static void LZ4_memcpy_using_offset(BYTE * dstPtr, const BYTE * srcPtr, BYTE * dstEnd, const size_t offset)

Defined at lz4.c#584

LZ4_memcpy_using_offset() presumes : - dstEnd >= dstPtr + MINMATCH - there is at least 12 bytes available to write after dstEnd

dir_ptr

static void * dir_ptr(Dir * dir)

Defined at fat.c#587


LZ4_XXH32_digest

XXH32_hash_t LZ4_XXH32_digest(const XXH32_state_t * statePtr)

Defined at xxhash.c#588

sfn_is_last

static _Bool sfn_is_last(Sfn * sfn)

Defined at fat.c#593


sfn_is_free

static _Bool sfn_is_free(Sfn * sfn)

Defined at fat.c#599


sfn_is_lfn

static _Bool sfn_is_lfn(Sfn * sfn)

Defined at fat.c#605


LZ4_XXH32_canonicalFromHash

void LZ4_XXH32_canonicalFromHash(XXH32_canonical_t * dst, XXH32_hash_t hash)

Defined at xxhash.c#607

Default XXH result types are basic unsigned 32 and 64 bits. The canonical representation follows human-readable write convention, aka big-endian (large digits first). These functions allow transformation of hash result into and from its canonical format. This way, hash values can be written into a file or buffer, remaining comparable across different systems.

sfn_cluster

static uint32_t sfn_cluster(Sfn * sfn)

Defined at fat.c#611


LZ4_XXH32_hashFromCanonical

XXH32_hash_t LZ4_XXH32_hashFromCanonical(const XXH32_canonical_t * src)

Defined at xxhash.c#615

sfn_char

static char sfn_char(char c)

Defined at fat.c#621

------------------------------------------------------------------------------ Only certain characters are allowed in an SFN file name. Invalid characters are converted to underscore. It does not follow Windows' algorithm, using ~N for duplicate names, since it relies on LFN names only.

static void print_integer(output_gadget_t * output, printf_unsigned_value_t value, _Bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags)

Defined at printf.c#624

An internal itoa-like function

LZ4_NbCommonBytes

static unsigned int LZ4_NbCommonBytes(reg_t val)

Defined at lz4.c#627

-***** Common functions*****

put_sfn_name

static void put_sfn_name(uint8_t * sfn_name, const char * name, int len)

Defined at fat.c#638


parse_sfn_name

static void parse_sfn_name(struct fat32fs_ctx * ctx, uint8_t * sfn_name)

Defined at fat.c#659


XXH_read64

static U64 XXH_read64(const void * memPtr)

Defined at xxhash.c#669

portable and safe solution. Generally efficient. see : http://stackoverflow.com/a/32095106/646947

put_lfn_name_frag

static void put_lfn_name_frag(Lfn * lfn, const char * name, int len)

Defined at fat.c#676


LZ4F_initStream

static void LZ4F_initStream(void * ctx, const LZ4F_CDict * cdict, int level, LZ4F_blockMode_t blockMode)

Defined at lz4frame.c#682

This function prepares the internal LZ4(HC) stream for a new compression, resetting the context and attaching the dictionary, if there is one.

It needs to be called at the beginning of each independent compression stream (i.e., at the beginning of a frame in blockLinked mode, or at the beginning of each block in blockIndependent mode).

XXH_swap64

static U64 XXH_swap64(U64 x)

Defined at xxhash.c#683

XXH_readLE64_align

static U64 XXH_readLE64_align(const void * ptr, XXH_endianness endian, XXH_alignment align)

Defined at xxhash.c#696

parse_lfn_name

static int parse_lfn_name(struct fat32fs_ctx * ctx, Dir * dir)

Defined at fat.c#696


XXH_readLE64

static U64 XXH_readLE64(const void * ptr, XXH_endianness endian)

Defined at xxhash.c#704

ctxTypeID_to_size

static int ctxTypeID_to_size(int ctxTypeID)

Defined at lz4frame.c#708

XXH_readBE64

static U64 XXH_readBE64(const void * ptr)

Defined at xxhash.c#709

get_components

static struct floating_point_components get_components(floating_point_t number, printf_size_t precision)

Defined at printf.c#712

Break up a non-negative, finite, floating-point number into two integral parts of its decimal representation: The number up to the decimal point, and the number appearing after that point - whose number of digits corresponds to the precision value. Example: The components of 12.621 are 12 and 621 for precision 3, or 12 and 62 for precision 2.

XXH64_round

static U64 XXH64_round(U64 acc, U64 input)

Defined at xxhash.c#722

XXH64_mergeRound

static U64 XXH64_mergeRound(U64 acc, U64 val)

Defined at xxhash.c#730

LZ4F_compressBegin_internal

static size_t LZ4F_compressBegin_internal(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const void * dictBuffer, size_t dictSize, const LZ4F_CDict * cdict, const LZ4F_preferences_t * preferencesPtr)

Defined at lz4frame.c#731

LZ4F_compressBegin_internal() Note: only accepts or as non NULL.

LZ4_count

static unsigned int LZ4_count(const BYTE * pIn, const BYTE * pMatch, const BYTE * pInLimit)

Defined at lz4.c#737

XXH64_avalanche

static U64 XXH64_avalanche(U64 h64)

Defined at xxhash.c#738

static int dir_search(struct fat32fs_ctx * ctx, Dir * dir, const char * name, int len, Loc * loc)

Defined at fat.c#745


XXH64_finalize

static U64 XXH64_finalize(U64 h64, const void * ptr, size_t len, XXH_endianness endian, XXH_alignment align)

Defined at xxhash.c#750

apply_scaling

static floating_point_t apply_scaling(floating_point_t num, struct scaling_factor normalization)

Defined at printf.c#757

unapply_scaling

static floating_point_t unapply_scaling(floating_point_t normalized, struct scaling_factor normalization)

Defined at printf.c#762

update_normalization

static struct scaling_factor update_normalization(struct scaling_factor sf, floating_point_t extra_multiplicative_factor)

Defined at printf.c#780

dir_at_root

static _Bool dir_at_root(Dir * dir)

Defined at fat.c#796


get_normalized_components

static struct floating_point_components get_normalized_components(_Bool negative, printf_size_t precision, floating_point_t non_normalized, struct scaling_factor normalization, int floored_exp10)

Defined at printf.c#802

follow_path

static int follow_path(struct fat32fs_ctx * ctx, Dir * dir, const char ** path, Loc * loc)

Defined at fat.c#804


LZ4_versionNumber

int LZ4_versionNumber()

Defined at lz4.c#818

-***** Local Utils*****

LZ4_versionString

const char * LZ4_versionString()

Defined at lz4.c#822

LZ4_compressBound

int LZ4_compressBound(int inputSize)

Defined at lz4.c#826

LZ4_compressBound() : Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible) This function is primarily useful for memory allocation purposes (destination buffer size). Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example). Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize) inputSize : max supported value is LZ4_MAX_INPUT_SIZE return : maximum output size in a "worst case" scenario or 0, if input size is incorrect (too large or negative)

LZ4HC_Insert

static void LZ4HC_Insert(LZ4HC_CCtx_internal * hc4, const BYTE * ip)

Defined at lz4hc.c#841

Update chains up to ip (excluded)

LZ4_hash4

static U32 LZ4_hash4(U32 sequence, const tableType_t tableType)

Defined at lz4.c#859

-**** Compression functions****

remove_entries

static int remove_entries(struct fat32fs_ctx * ctx, Dir * dir, Loc * loc)

Defined at fat.c#860


static void print_broken_up_decimal(struct floating_point_components number_, output_gadget_t * output, printf_size_t precision, printf_size_t width, printf_flags_t flags, char * buf, printf_size_t len)

Defined at printf.c#860

LZ4_hash5

static U32 LZ4_hash5(U64 sequence, const tableType_t tableType)

Defined at lz4.c#867

LZ4HC_rotatePattern

static U32 LZ4HC_rotatePattern(const size_t rotate, const U32 pattern)

Defined at lz4hc.c#871

LZ4_hashPosition

static U32 LZ4_hashPosition(const void const p, const tableType_t tableType)*

Defined at lz4.c#879

LZ4F_compressBegin_usingDictOnce

static size_t LZ4F_compressBegin_usingDictOnce(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const void * dict, size_t dictSize, const LZ4F_preferences_t * preferencesPtr)

Defined at lz4frame.c#880

LZ4F_compressBegin_usingDictOnce: Hidden implementation, employed for multi-threaded compression when frame defines linked blocks

LZ4HC_countPattern

static unsigned int LZ4HC_countPattern(const BYTE * ip, const BYTE const iEnd, const U32 pattern32)*

Defined at lz4hc.c#881

LZ4HC_countPattern() : pattern32 must be a sample of repetitive pattern of length 1, 2 or 4 (but not 3!)

XXH64_endian_align

static U64 XXH64_endian_align(const void * input, size_t len, U64 seed, XXH_endianness endian, XXH_alignment align)

Defined at xxhash.c#890

dir_add

static int dir_add(struct fat32fs_ctx * ctx, Dir * dir, const char * name, int len, uint8_t attr, uint32_t clust)

Defined at fat.c#890


LZ4_clearHash

static void LZ4_clearHash(U32 h, void * tableBase, const tableType_t tableType)

Defined at lz4.c#891

LZ4_putIndexOnHash

static void LZ4_putIndexOnHash(U32 idx, U32 h, void * tableBase, const tableType_t tableType)

Defined at lz4.c#917

LZ4HC_reverseCountPattern

static unsigned int LZ4HC_reverseCountPattern(const BYTE * ip, const BYTE const iLow, U32 pattern)*

Defined at lz4hc.c#921

LZ4HC_reverseCountPattern() : pattern must be a sample of repetitive pattern of length 1, 2 or 4 (but not 3!) read using natural platform endianness

LZ4F_makeBlock

static size_t LZ4F_makeBlock(void * dst, const void * src, size_t srcSize, compressFunc_t compress, void * lz4ctx, int level, const LZ4F_CDict * cdict, LZ4F_blockChecksum_t crcFlag)

Defined at lz4frame.c#924

LZ4F_makeBlock(): compress a single block, add header and optional checksum. assumption : dst buffer capacity is >= BHSize + srcSize + crcSize

LZ4_XXH64

XXH64_hash_t LZ4_XXH64(const void * input, size_t length, unsigned long long seed)

Defined at xxhash.c#937

XXH64() : Calculate the 64-bit hash of sequence of length "len" stored at memory address "input". "seed" can be used to alter the result predictably. This function runs faster on 64-bit systems, but slower on 32-bit systems (see benchmark).

LZ4_putPositionOnHash

static void LZ4_putPositionOnHash(const BYTE * p, U32 h, void * tableBase, const tableType_t tableType)

Defined at lz4.c#941

LZ4_putPosition*() : only used in byPtr mode

static void print_decimal_number(output_gadget_t * output, floating_point_t number, printf_size_t precision, printf_size_t width, printf_flags_t flags, char * buf, printf_size_t len)

Defined at printf.c#943

internal ftoa for fixed decimal floating point

LZ4HC_protectDictEnd

static int LZ4HC_protectDictEnd(const U32 dictLimit, const U32 matchIndex)

Defined at lz4hc.c#947

LZ4HC_protectDictEnd() : Checks if the match is in the last 3 bytes of the dictionary, so reading the 4 byte MINMATCH would overflow.

returns true if the match index is okay.

LZ4F_compressBlock

static int LZ4F_compressBlock(void * ctx, const char * src, char * dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict * cdict)

Defined at lz4frame.c#948

LZ4_putPosition

static void LZ4_putPosition(const BYTE * p, void * tableBase, tableType_t tableType)

Defined at lz4.c#949

LZ4HC_InsertAndGetWiderMatch

static LZ4HC_match_t LZ4HC_InsertAndGetWiderMatch(LZ4HC_CCtx_internal const hc4, const BYTE const ip, const BYTE const iLowLimit, const BYTE const iHighLimit, int longest, const int maxNbAttempts, const int patternAnalysis, const int chainSwap, const dictCtx_directive dict, const HCfavor_e favorDecSpeed)

Defined at lz4hc.c#955

bastardized_floor

static int bastardized_floor(floating_point_t x)

Defined at printf.c#956

A floor function - but one which only works for numbers whose floor value is representable by an int.

LZ4_getIndexOnHash

static U32 LZ4_getIndexOnHash(U32 h, const void * tableBase, tableType_t tableType)

Defined at lz4.c#961

LZ4_getIndexOnHash() : Index of match position registered in hash table. hash position must be calculated by using base+index, or dictBase+index. Assumption 1 : only valid if tableType == byU32 or byU16. Assumption 2 : h is presumed valid (within limits of hash table)

LZ4F_compressBlock_continue

static int LZ4F_compressBlock_continue(void * ctx, const char * src, char * dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict * cdict)

Defined at lz4frame.c#962

LZ4_XXH64_createState

XXH64_state_t * LZ4_XXH64_createState()

Defined at xxhash.c#966

====== Hash Streaming ======

LZ4_XXH64_freeState

XXH_errorcode LZ4_XXH64_freeState(XXH64_state_t * statePtr)

Defined at xxhash.c#970

log10_of_positive

static floating_point_t log10_of_positive(floating_point_t positive_number)

Defined at printf.c#970

Computes the base-10 logarithm of the input number - which must be an actual positive number (not infinity or NaN, nor a sub-normal)

LZ4F_compressBlockHC

static int LZ4F_compressBlockHC(void * ctx, const char * src, char * dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict * cdict)

Defined at lz4frame.c#972

LZ4_XXH64_copyState

void LZ4_XXH64_copyState(XXH64_state_t * dst_state, const XXH64_state_t * src_state)

Defined at xxhash.c#976

LZ4_getPositionOnHash

static const BYTE * LZ4_getPositionOnHash(U32 h, const void * tableBase, tableType_t tableType)

Defined at lz4.c#978

LZ4_compress_HC

int LZ4_compress_HC(const char * src, char * dst, int srcSize, int dstCapacity, int compressionLevel)

Defined at lz4hc.c#1637

-***** Block Compression*****

LZ4_compress_HC() : Compress data from src into dst, using the powerful but slower "HC" algorithm. dst must be already allocated. Compression is guaranteed to succeed if dstCapacity >= LZ4_compressBound(srcSize) (see "lz4.h") Max supported srcSize value is LZ4_MAX_INPUT_SIZE (see "lz4.h") compressionLevel : any value between 1 and LZ4HC_CLEVEL_MAX will work. Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.

return : the number of bytes written into 'dst' or 0 if compression fails.

LZ4_sizeofStateHC

int LZ4_sizeofStateHC()

Defined at lz4hc.c#1591

LZ4_compress_HC_extStateHC() : Same as LZ4_compress_HC(), but using an externally allocated memory segment for state. state size is provided by LZ4_sizeofStateHC(). Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).

LZ4_compress_HC_extStateHC

int LZ4_compress_HC_extStateHC(void * stateHC, const char * src, char * dst, int srcSize, int maxDstSize, int compressionLevel)

Defined at lz4hc.c#1627

LZ4_compress_HC_destSize

int LZ4_compress_HC_destSize(void * stateHC, const char * src, char * dst, int * srcSizePtr, int targetDstSize, int compressionLevel)

Defined at lz4hc.c#1657

LZ4_compress_HC_destSize() : v1.9.0+ Will compress as much data as possible from src to fit into targetDstSize budget. Result is provided in 2 parts :

return : the number of bytes written into 'dst' (necessarily <= targetDstSize) or 0 if compression fails. srcSizePtr : on success, *srcSizePtr is updated to indicate how much bytes were read from src

state is presumed sized correctly (>= sizeof(LZ4_streamHC_t))

LZ4_createStreamHC

LZ4_streamHC_t * LZ4_createStreamHC()

Defined at lz4hc.c#1674

LZ4_createStreamHC() and LZ4_freeStreamHC() : These functions create and release memory for LZ4 HC streaming state. Newly created states are automatically initialized. A same state can be used multiple times consecutively, starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.

LZ4_freeStreamHC

int LZ4_freeStreamHC(LZ4_streamHC_t * streamHCPtr)

Defined at lz4hc.c#1683

LZ4_resetStreamHC_fast

void LZ4_resetStreamHC_fast(LZ4_streamHC_t * streamHCPtr, int compressionLevel)

Defined at lz4hc.c#1720

These functions compress data in successive blocks of any size, using previous blocks as dictionary, to improve compression ratio. One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks. There is an exception for ring buffers, which can be smaller than 64 KB. Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue().

Before starting compression, state must be allocated and properly initialized. LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT.

Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream) or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental). LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once, which is automatically the case when state is created using LZ4_createStreamHC().

After reset, a first "fictional block" can be designated as initial dictionary, using LZ4_loadDictHC() (Optional). Note: In order for LZ4_loadDictHC() to create the correct data structure, it is essential to set the compression level before loading the dictionary.

Invoke LZ4_compress_HC_continue() to compress each successive block. The number of blocks is unlimited. Previous input blocks, including initial dictionary when present, must remain accessible and unmodified during compression.

It's allowed to update compression level anytime between blocks, using LZ4_setCompressionLevel() (experimental).

buffer should be sized to handle worst case scenarios

(see LZ4_compressBound(), it ensures compression success).

In case of failure, the API does not guarantee recovery,

so the state must be reset.

To ensure compression success

whenever @dst buffer size cannot be made >= LZ4_compressBound(),

consider using LZ4_compress_HC_continue_destSize().

Whenever previous input blocks can't be preserved unmodified in-place during compression of next

blocks, it's possible to copy the last blocks into a more stable memory space, using

LZ4_saveDictHC(). Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into

'safeBuffer' (<= 64 KB)

After completing a streaming compression,

it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state,

just by resetting it, using LZ4_resetStreamHC_fast().

LZ4_resetStreamHC_fast() : v1.9.0+ When an LZ4_streamHC_t is known to be in a internally coherent state, it can often be prepared for a new compression with almost no work, only sometimes falling back to the full, expensive reset that is always required when the stream is in an indeterminate state (i.e., the reset performed by LZ4_resetStreamHC()).

LZ4_streamHCs are guaranteed to be in a valid state when: - returned from LZ4_createStreamHC() - reset by LZ4_resetStreamHC() - memset(stream, 0, sizeof(LZ4_streamHC_t)) - the stream was in a valid state and was reset by LZ4_resetStreamHC_fast() - the stream was in a valid state and was then used in any compression call that returned success - the stream was in an indeterminate state and was used in a compression call that fully reset the state (LZ4_compress_HC_extStateHC()) and that returned success

Note: A stream that was last used in a compression call that returned an error may be passed to this function. However, it will be fully reset, which will clear any existing history and settings from the context.

LZ4_loadDictHC

int LZ4_loadDictHC(LZ4_streamHC_t * streamHCPtr, const char * dictionary, int dictSize)

Defined at lz4hc.c#1753

LZ4_loadDictHC() : LZ4_streamHCPtr is presumed properly initialized

LZ4_compress_HC_continue

int LZ4_compress_HC_continue(LZ4_streamHC_t * streamHCPtr, const char * src, char * dst, int srcSize, int maxDstSize)

Defined at lz4hc.c#1857

LZ4_compress_HC_continue_destSize

int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t * LZ4_streamHCPtr, const char * src, char * dst, int * srcSizePtr, int targetDstSize)

Defined at lz4hc.c#1869

LZ4_compress_HC_continue_destSize() : v1.9.0+ Similar to LZ4_compress_HC_continue(), but will read as much data as possible from src to fit into targetDstSize budget. Result is provided into 2 parts :

return : the number of bytes written into 'dst' (necessarily <= targetDstSize) or 0 if compression fails. srcSizePtr : on success, *srcSizePtr will be updated to indicate how much bytes were read from src. Note that this function may not consume the entire input.

LZ4_saveDictHC

int LZ4_saveDictHC(LZ4_streamHC_t * streamHCPtr, char * safeBuffer, int maxDictSize)

Defined at lz4hc.c#1881

LZ4_saveDictHC : save history content into a user-provided buffer which is then used to continue compression

LZ4_saveDictHC(): save history content (up to 64 KB) into a user-provided buffer

safeBuffer.

return value is the size of dictionary effectively saved (<= MIN(maxDictSize, 64 KB)). This function is always successful, and expects its arguments to be valid. To this end, let's remind that (NULL,0) is valid, but (NULL,!0) is not, and will result in a segfault (or assert() depending on compilation mode).

LZ4_compress_default

int LZ4_compress_default(const char * src, char * dst, int srcSize, int dstCapacity)

Defined at lz4.c#1645

-***** Simple Functions*****

LZ4_compress_default() : Compresses 'srcSize' bytes from buffer 'src' into already allocated 'dst' buffer of size 'dstCapacity'. Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize). It also runs faster, so it's a recommended setting. If the function cannot compress 'src' into a more limited 'dst' budget, compression stops immediately, and the function result is zero. In which case, 'dst' content is undefined (invalid). srcSize : max supported value is LZ4_MAX_INPUT_SIZE. dstCapacity : size of buffer 'dst' (which must be already allocated)

return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity) or 0 if compression fails Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).

LZ4_attach_HC_dictionary

void LZ4_attach_HC_dictionary(LZ4_streamHC_t * working_stream, const LZ4_streamHC_t * dictionary_stream)

Defined at lz4hc.c#1783

LZ4_attach_HC_dictionary() : stable since v1.10.0 This API allows for the efficient re-use of a static dictionary many times.

Rather than re-loading the dictionary buffer into a working context before each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a working LZ4_streamHC_t, this function introduces a no-copy setup mechanism, in which the working stream references the dictionary stream in-place.

Several assumptions are made about the state of the dictionary stream. Currently, only streams which have been prepared by LZ4_loadDictHC() should be expected to work.

Alternatively, the provided dictionary stream pointer may be NULL, in which case any existing dictionary stream is unset.

A dictionary should only be attached to a stream without any history (i.e., a stream that has just been reset).

The dictionary will remain attached to the working stream only for the current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the dictionary context association from the working stream. The dictionary stream (and source buffer) must remain in-place / accessible / unchanged through the lifetime of the stream session.

LZ4_decompress_safe

int LZ4_decompress_safe(const char * src, char * dst, int compressedSize, int dstCapacity)

Defined at lz4.c#2734

LZ4_decompress_safe() : : is the exact complete size of the compressed block. : is the size of destination buffer (which must be already allocated), presumed an upper bound of decompressed size.

return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity) If destination buffer is not large enough, decoding will stop and output an error code (negative value). If the source stream is detected malformed, the function will stop decoding and return a negative result. Note 1 : This function is protected against malicious data packets : it will never writes outside 'dst' buffer, nor read outside 'source' buffer, even if the compressed block is maliciously modified to order the decoder to do these actions. In such case, the decoder stops immediately, and considers the compressed block malformed. Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them. The implementation is free to send / store / derive this information in whichever way is most beneficial. If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.

===== Instantiate the API decoding functions. =====

LZ4_compress_fast

int LZ4_compress_fast(const char * src, char * dst, int srcSize, int dstCapacity, int acceleration)

Defined at lz4.c#1625

LZ4_compress_fast() : Same as LZ4_compress_default(), but allows selection of "acceleration" factor. The larger the acceleration value, the faster the algorithm, but also the lesser the compression. It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. An acceleration value of "1" is the same as regular LZ4_compress_default() Values<= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c). Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c).

LZ4_XXH64_reset

XXH_errorcode LZ4_XXH64_reset(XXH64_state_t * statePtr, unsigned long long seed)

Defined at xxhash.c#981

LZ4_sizeofState

int LZ4_sizeofState()

Defined at lz4.c#830

LZ4_compress_fast_extState() : Same as LZ4_compress_fast(), using an externally allocated memory space for its state. Use LZ4_sizeofState() to know how much memory must be allocated, and allocate it on 8-bytes boundaries (using malloc() typically). Then, provide this buffer as void* state to compression function.

LZ4F_getVersion

unsigned int LZ4F_getVersion()

Defined at lz4frame.c#339

LZ4F_createCompressionContext

LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx ** cctxPtr, unsigned int version)

Defined at lz4frame.c#652

LZ4F_createCompressionContext() : The first thing to do is to create a compressionContext object, which will keep track of operation state during streaming compression. This is achieved using LZ4F_createCompressionContext(), which takes as argument a version, and a pointer to LZ4F_cctx*, to write the resulting pointer into.

version provided MUST be LZ4F_VERSION. It is intended to track potential version mismatch, notably when using DLL. The function provides a pointer to a fully allocated LZ4F_cctx object. MUST be != NULL. If

return != zero, context creation failed. A created compression context can be employed multiple times for consecutive streaming operations. Once all streaming compression jobs are completed, the state object can be released using LZ4F_freeCompressionContext(). Note1 : LZ4F_freeCompressionContext() is always successful. Its return value can be ignored. Note2 : LZ4F_freeCompressionContext() works fine with NULL input pointers (do nothing).

LZ4F_createCompressionContext() : The first thing to do is to create a compressionContext object, which will be used in all compression operations. This is achieved using LZ4F_createCompressionContext(), which takes as argument a version and an LZ4F_preferences_t structure. The version provided MUST be LZ4F_VERSION. It is intended to track potential incompatible differences between different binaries. The function will provide a pointer to an allocated LZ4F_compressionContext_t object. If the result LZ4F_errorCode_t is not OK_NoError, there was an error during context creation. Object can release its memory using LZ4F_freeCompressionContext();

LZ4F_freeCompressionContext

LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx * cctx)

Defined at lz4frame.c#663

LZ4F_compressBegin

size_t LZ4F_compressBegin(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const LZ4F_preferences_t * prefsPtr)

Defined at lz4frame.c#870

LZ4F_compressBegin() : will write the frame header into dstBuffer. dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes. prefsPtr is optional : NULL can be provided to set all preferences to default.

return : number of bytes written into dstBuffer for the header or an error code (which can be tested using LZ4F_isError())

LZ4F_compressBound

size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t * prefsPtr)

Defined at lz4frame.c#909

LZ4F_compressBound() :

return minimum capacity of dstBuffer for a given srcSize to handle worst case scenario. LZ4F_preferences_t structure is optional : if NULL, preferences will be set to cover worst case scenario. This function cannot fail.

LZ4F_compressBound() : Provides minimum dstCapacity required to guarantee success of LZ4F_compressUpdate(), given a srcSize and preferences, for a worst case scenario. When srcSize==0, LZ4F_compressBound() provides an upper bound for LZ4F_flush() and LZ4F_compressEnd() instead. Note that the result is only valid for a single invocation of LZ4F_compressUpdate(). When invoking LZ4F_compressUpdate() multiple times, if the output buffer is gradually filled up instead of emptied and re-used from its start, one must check if there is enough remaining capacity before each invocation, using LZ4F_compressBound().

return is always the same for a srcSize and prefsPtr. prefsPtr is optional : when NULL is provided, preferences will be set to cover worst case scenario. tech details :

return if automatic flushing is not enabled, includes the possibility that internal buffer might already be filled by up to (blockSize-1) bytes. It also includes frame footer (ending + checksum), since it might be generated by LZ4F_compressEnd().

return doesn't include frame header, as it was already generated by LZ4F_compressBegin().

LZ4F_compressBegin_usingDict

size_t LZ4F_compressBegin_usingDict(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const void * dictBuffer, size_t dictSize, const LZ4F_preferences_t * prefsPtr)

Defined at lz4frame.c#888

LZ4F_compressBegin_usingDict() : stable since v1.10 Inits dictionary compression streaming, and writes the frame header into dstBuffer. must be >= LZ4F_HEADER_SIZE_MAX bytes. is optional : one may provide NULL as argument, however, it's the only way to provide dictID in the frame header. must outlive the compression session.

return : number of bytes written into dstBuffer for the header, or an error code (which can be tested using LZ4F_isError()) NOTE: The LZ4Frame spec allows each independent block to be compressed with the dictionary, but this entry supports a more limited scenario, where only the first block uses the dictionary. This is still useful for small data, which only need one block anyway. For larger inputs, one may be more interested in LZ4F_compressFrame_usingCDict() below.

LZ4F_createCDict

LZ4F_CDict * LZ4F_createCDict(const void * dictBuffer, size_t dictSize)

Defined at lz4frame.c#610

LZ4F_createCDict() : When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once. LZ4F_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. LZ4F_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. can be released after LZ4F_CDict creation, since its content is copied within CDict

return : digested dictionary for compression, or NULL if failed

LZ4_createCDict() : stable since v1.10 When compressing multiple messages / blocks using the same dictionary, it's recommended to initialize it just once. LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay. LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. can be released after LZ4_CDict creation, since its content is copied within CDict.

LZ4F_freeCDict

void LZ4F_freeCDict(LZ4F_CDict * CDict)

Defined at lz4frame.c#616

LZ4F_compressFrame_usingCDict

size_t LZ4F_compressFrame_usingCDict(LZ4F_cctx * cctx, void * dst, size_t dstCapacity, const void * src, size_t srcSize, const LZ4F_CDict * cdict, const LZ4F_preferences_t * preferencesPtr)

Defined at lz4frame.c#452

LZ4F_compressFrame_usingCDict() : Compress srcBuffer using a dictionary, in a single step. cdict can be NULL, in which case, no dictionary is used. dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). The LZ4F_preferences_t structure is optional : you may provide NULL as argument, however, it's the only way to provide a dictID, so it's not recommended.

return : number of bytes written into dstBuffer, or an error code if it fails (can be tested using LZ4F_isError())

LZ4_compressFrame_usingCDict() : stable since v1.10 Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary. must point to a context created by LZ4F_createCompressionContext(). If ==NULL, compress without a dictionary. MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr). If this condition is not respected, function will fail (

return an errorCode). The LZ4F_preferences_t structure is optional : one may provide NULL as argument, but it's not recommended, as it's the only way to provide in the frame header.

return : number of bytes written into dstBuffer. or an error code if it fails (can be tested using LZ4F_isError()) Note: for larger inputs generating multiple independent blocks, this entry point uses the dictionary for each block.

LZ4F_compressBegin_usingCDict

size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const LZ4F_CDict * cdict, const LZ4F_preferences_t * prefsPtr)

Defined at lz4frame.c#898

LZ4F_compressBegin_usingCDict() : stable since v1.10 Inits streaming dictionary compression, and writes the frame header into dstBuffer. must be >= LZ4F_HEADER_SIZE_MAX bytes. is optional : one may provide NULL as argument, note however that it's the only way to insert a in the frame header. must outlive the compression session.

return : number of bytes written into dstBuffer for the header, or an error code, which can be tested using LZ4F_isError().

LZ4F_getErrorCode

LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult)

Defined at lz4frame.c#309

LZ4F_getBlockSize

size_t LZ4F_getBlockSize(LZ4F_blockSizeID_t blockSizeID)

Defined at lz4frame.c#349

LZ4F_getBlockSize() :

return, in scalar format (size_t), the maximum block size associated with , or an error code (can be tested using LZ4F_isError()) if is invalid.

LZ4F_createCompressionContext_advanced

LZ4F_cctx * LZ4F_createCompressionContext_advanced(LZ4F_CustomMem customMem, unsigned int version)

Defined at lz4frame.c#630

-***** Advanced compression functions*******

LZ4F_createCDict_advanced

LZ4F_CDict * LZ4F_createCDict_advanced(LZ4F_CustomMem customMem, const void * dictBuffer, size_t dictSize)

Defined at lz4frame.c#566

LZ4F_cctx_size

size_t LZ4F_cctx_size(const LZ4F_cctx * cctx)

Defined at lz4frame.c#720

Context size inspection : v1.10.1+ These functions return the total memory footprint of the provided context.

LZ4F_compressBlockHC_continue

static int LZ4F_compressBlockHC_continue(void * ctx, const char * src, char * dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict * cdict)

Defined at lz4frame.c#982

LZ4_getPosition

static const BYTE * LZ4_getPosition(const BYTE * p, const void * tableBase, tableType_t tableType)

Defined at lz4.c#988

LZ4F_doNotCompressBlock

static int LZ4F_doNotCompressBlock(void * ctx, const char * src, char * dst, int srcSize, int dstCapacity, int level, const LZ4F_CDict * cdict)

Defined at lz4frame.c#990

LZ4_prepareTable

static void LZ4_prepareTable(LZ4_stream_t_internal const cctx, const int inputSize, const tableType_t tableType)*

Defined at lz4.c#994

XXH64_update_endian

static XXH_errorcode XXH64_update_endian(XXH64_state_t * state, const void * input, size_t len, XXH_endianness endian)

Defined at xxhash.c#995

check_fat

static _Bool check_fat(uint8_t * buf)

Defined at fat.c#1000


LZ4F_selectCompression

static compressFunc_t LZ4F_selectCompression(LZ4F_blockMode_t blockMode, int level, LZ4F_BlockCompressMode_e compressMode)

Defined at lz4frame.c#1003

pow10_of_int

static floating_point_t pow10_of_int(int floored_exp10)

Defined at printf.c#1016

LZ4F_localSaveDict

static void LZ4F_localSaveDict(LZ4F_cctx_t * cctxPtr)

Defined at lz4frame.c#1019

Save or shorten history (up to 64KB) into

fat_mount

int fat_mount(struct fat32fs_ctx * ctx, Fat * fat)

Defined at fat.c#1038

------------------------------------------------------------------------------ Mounts a file system. The name specifies which path is used to access it. For example: mounting using 'mnt', and accessing using '/mnt/path/file.txt'. Partition 0 referes to either the entire disk (absense of MBR), or to the specified MBR partition.

LZ4_compress_generic_validated

static int LZ4_compress_generic_validated(LZ4_stream_t_internal const cctx, const char const source, char const dest, const int inputSize, int * inputConsumed, const int maxOutputSize, const limitedOutput_directive outputDirective, const tableType_t tableType, const dict_directive dictDirective, const dictIssue_directive dictIssue, const int acceleration)*

Defined at lz4.c#1039

LZ4_compress_generic_validated() : inlined, to ensure branches are decided at compilation time. The following conditions are presumed already validated: - source != NULL - inputSize > 0

static void print_exponential_number(output_gadget_t * output, floating_point_t number, printf_size_t precision, printf_size_t width, printf_flags_t flags, char * buf, printf_size_t len)

Defined at printf.c#1045

LZ4F_compressUpdateImpl

static size_t LZ4F_compressUpdateImpl(LZ4F_cctx * cctxPtr, void * dstBuffer, size_t dstCapacity, const void * srcBuffer, size_t srcSize, const LZ4F_compressOptions_t * compressOptionsPtr, LZ4F_BlockCompressMode_e blockCompression)

Defined at lz4frame.c#1046

LZ4F_compressUpdateImpl() : LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. When successful, the function always entirely consumes . src data is either buffered or compressed into . If the block compression does not match the compression of the previous block, the old data is flushed and operations continue with the new compression mode. MUST be >= LZ4F_compressBound(srcSize, preferencesPtr) when block compression is turned on. is optional : provide NULL to mean "default".

return : the number of bytes written into dstBuffer. It can be zero, meaning input data was just buffered. or an error code if it fails (which can be tested using LZ4F_isError()) After an error, the state is left in a UB state, and must be re-initialized.

LZ4_XXH64_update

XXH_errorcode LZ4_XXH64_update(XXH64_state_t * statePtr, const void * input, size_t length)

Defined at xxhash.c#1059

XXH64_digest_endian

static U64 XXH64_digest_endian(const XXH64_state_t * state, XXH_endianness endian)

Defined at xxhash.c#1069

LZ4_XXH64_digest

XXH64_hash_t LZ4_XXH64_digest(const XXH64_state_t * statePtr)

Defined at xxhash.c#1093

fat_umount

int fat_umount(struct fat32fs_ctx * ctx, Fat * fat)

Defined at fat.c#1095

------------------------------------------------------------------------------ Syncronizes unwritten changes and removes the fat from the global list. All file must be closed before calling this.

fat_sync

int fat_sync(struct fat32fs_ctx * ctx, Fat * fat)

Defined at fat.c#1103

------------------------------------------------------------------------------ Synchronizes unwritten changes. Does not synchronize open files.

LZ4_XXH64_canonicalFromHash

void LZ4_XXH64_canonicalFromHash(XXH64_canonical_t * dst, XXH64_hash_t hash)

Defined at xxhash.c#1105

====== Canonical representation ======

fat_stat

int fat_stat(struct fat32fs_ctx * ctx, const char * path, DirInfo * info)

Defined at fat.c#1111

------------------------------------------------------------------------------ Get information about a file or directory.

LZ4_XXH64_hashFromCanonical

XXH64_hash_t LZ4_XXH64_hashFromCanonical(const XXH64_canonical_t * src)

Defined at xxhash.c#1113

int fat_unlink(struct fat32fs_ctx * ctx, const char * path)

Defined at fat.c#1141

------------------------------------------------------------------------------ Unlinks (deletes) an existing file or empty directory.

LZ4F_compressUpdate

size_t LZ4F_compressUpdate(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const void * srcBuffer, size_t srcSize, const LZ4F_compressOptions_t * cOptPtr)

Defined at lz4frame.c#1176

LZ4F_compressUpdate() : LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. Important rule: dstCapacity MUST be large enough to ensure operation success even in worst case situations. This value is provided by LZ4F_compressBound(). If this condition is not respected, LZ4F_compress() will fail (result is an errorCode). After an error, the state is left in a UB state, and must be re-initialized or freed. If previously an uncompressed block was written, buffered data is flushed before appending compressed data is continued. cOptPtr is optional : NULL can be provided, in which case all options are set to default.

return : number of bytes written into dstBuffer (it can be zero, meaning input data was just buffered). or an error code if it fails (which can be tested using LZ4F_isError())

LZ4F_compressUpdate() : LZ4F_compressUpdate() can be called repetitively to compress as much data as necessary. When successful, the function always entirely consumes . src data is either buffered or compressed into . If previously an uncompressed block was written, buffered data is flushed before appending compressed data is continued. MUST be >= LZ4F_compressBound(srcSize, preferencesPtr). is optional : provide NULL to mean "default".

return : the number of bytes written into dstBuffer. It can be zero, meaning input data was just buffered. or an error code if it fails (which can be tested using LZ4F_isError()) After an error, the state is left in a UB state, and must be re-initialized.

LZ4F_flush

size_t LZ4F_flush(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t * cOptPtr)

Defined at lz4frame.c#1208

LZ4F_flush() : When compressed data must be sent immediately, without waiting for a block to be filled, invoke LZ4F_flush(), which will immediately compress any remaining data stored within LZ4F_cctx. The result of the function is the number of bytes written into dstBuffer. It can be zero, this means there was no data left within LZ4F_cctx. The function outputs an error code if it fails (can be tested using LZ4F_isError()) LZ4F_compressOptions_t* is optional. NULL is a valid argument.

LZ4F_flush() : When data must be generated and sent immediately, without waiting for a block to be completely filled, it's possible to call LZ4_flush(). It will immediately compress any data buffered within cctx. dstCapacity must be large enough to ensure the operation will be successful. cOptPtr is optional : it's possible to provide NULL, all options will be set to default.

return : nb of bytes written into dstBuffer (can be zero, when there is no data stored within cctx) or an error code if it fails (which can be tested using LZ4F_isError()) Note : LZ4F_flush() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr).

fat_file_open

int fat_file_open(struct fat32fs_ctx * ctx, File * file, const char * path, uint8_t flags)

Defined at fat.c#1208

------------------------------------------------------------------------------ Opens a file. The file structure contain the size and offset that can be read by the user at any point. Any combination of the following flags can be used:

  • FAT_WRITE: open for writing - FAT_READ: open for reading - FAT_APPEND: place file cursor at the end of the file - FAT_TRUNC: truncate the file - FAT_CREATE: create file if not existing

LZ4HC_InsertAndFindBestMatch

static LZ4HC_match_t LZ4HC_InsertAndFindBestMatch(LZ4HC_CCtx_internal const hc4, const BYTE const ip, const BYTE const iLimit, const int maxNbAttempts, const int patternAnalysis, const dictCtx_directive dict)*

Defined at lz4hc.c#1217

static void print_floating_point(output_gadget_t * output, floating_point_t value, printf_size_t precision, printf_size_t width, printf_flags_t flags, _Bool prefer_exponential)

Defined at printf.c#1223

LZ4HC_compress_hashChain

static int LZ4HC_compress_hashChain(LZ4HC_CCtx_internal const ctx, const char const src, char const dst, int * srcSizePtr, const int maxOutputSize, int maxNbAttempts, const limitedOutput_directive limit, const dictCtx_directive dict)*

Defined at lz4hc.c#1237

preconditions: - *srcSizePtr within [1, LZ4_MAX_INPUT_SIZE] - src is valid - maxOutputSize >= 1 - dst is valid

fat_file_close

int fat_file_close(struct fat32fs_ctx * ctx, File * file)

Defined at fat.c#1262

------------------------------------------------------------------------------ Closes a file. Updates the directory entry if modified. Writes back the write buffer if dirty.

fat_file_read

int fat_file_read(struct fat32fs_ctx * ctx, File * file, void * buf, int len, int * bytes)

Defined at fat.c#1270


parse_flags

static printf_flags_t parse_flags(const char ** format)

Defined at printf.c#1285

Advances the format pointer past the flags, and returns the parsed flags due to the characters passed

fat_file_write

int fat_file_write(struct fat32fs_ctx * ctx, File * file, const void * buf, int len, int * bytes)

Defined at fat.c#1305

------------------------------------------------------------------------------ Write a number of bytes to the file. It allocates more clusters if the write exceeds the allocated space. It return the error code and the number of bytes written.

format_string_loop

static void format_string_loop(output_gadget_t * output, const char * format, va_list args)

Defined at printf.c#1316

fat_file_seek

int fat_file_seek(struct fat32fs_ctx * ctx, File * file, int offset, int seek)

Defined at fat.c#1350

------------------------------------------------------------------------------ Seek into the file. This is internally used to update the file buffer and extend the file when needed. For a user, this is used to ether:

  • Update the offset of subsequent reads and writes - Preallocate space in the file (just seek the number of bytes to allocate)

Seeking backwards take more time as the cluster chain (often) must be followed from the beginning.

LZ4F_decodeHeader

static size_t LZ4F_decodeHeader(LZ4F_dctx * dctx, const void * src, size_t srcSize)

Defined at lz4frame.c#1408

LZ4F_decodeHeader() : input : src points at the beginning of the frame output : set internal values of dctx, such as dctx->frameInfo and dctx->dStage. Also allocates internal buffers.

return : nb Bytes read from src (necessarily <= srcSize) or an error code (testable with LZ4F_isError())

fat_file_sync

int fat_file_sync(struct fat32fs_ctx * ctx, File * file)

Defined at fat.c#1429

------------------------------------------------------------------------------ Synchronizes a file. Writes back dirty file data. Updates directory timestamp when accessed. Update directory size and timestamp when modified.

fat_dir_create

int fat_dir_create(struct fat32fs_ctx * ctx, Dir * dir, const char * path)

Defined at fat.c#1472

------------------------------------------------------------------------------ Creates and enter a directory. Don't know if there is any point in returning dir.

LZ4_compress_generic

static int LZ4_compress_generic(LZ4_stream_t_internal const cctx, const char const src, char const dst, const int srcSize, int * inputConsumed, const int dstCapacity, const limitedOutput_directive outputDirective, const tableType_t tableType, const dict_directive dictDirective, const dictIssue_directive dictIssue, const int acceleration)*

Defined at lz4.c#1497

LZ4_compress_generic() : inlined, to ensure branches are decided at compilation time; takes care of src == (NULL, 0) and forward the rest to LZ4_compress_generic_validated

LZ4HC_compress_generic_internal

static int LZ4HC_compress_generic_internal(LZ4HC_CCtx_internal const ctx, const char const src, char const dst, int const srcSizePtr, const int dstCapacity, int cLevel, const limitedOutput_directive limit, const dictCtx_directive dict)

Defined at lz4hc.c#1497

LZ4_compress_fast_extState

int LZ4_compress_fast_extState(void * state, const char * src, char * dst, int srcSize, int dstCapacity, int acceleration)

Defined at lz4.c#1530

fat_dir_open

int fat_dir_open(struct fat32fs_ctx * ctx, Dir * dir, const char * path)

Defined at fat.c#1532


LZ4HC_compress_generic_noDictCtx

static int LZ4HC_compress_generic_noDictCtx(LZ4HC_CCtx_internal const ctx, const char const src, char const dst, int const srcSizePtr, const int dstCapacity, int cLevel, limitedOutput_directive limit)

Defined at lz4hc.c#1544

isStateCompatible

static int isStateCompatible(const LZ4HC_CCtx_internal * ctx1, const LZ4HC_CCtx_internal * ctx2)

Defined at lz4hc.c#1553

fat_dir_read

int fat_dir_read(struct fat32fs_ctx * ctx, Dir * dir, DirInfo * info)

Defined at fat.c#1558

------------------------------------------------------------------------------ Read directory entry pointed to by dir. Use dir_next to advance directory pointer.

LZ4HC_compress_generic_dictCtx

static int LZ4HC_compress_generic_dictCtx(LZ4HC_CCtx_internal const ctx, const char const src, char const dst, int const srcSizePtr, const int dstCapacity, int cLevel, limitedOutput_directive limit)

Defined at lz4hc.c#1560

LZ4HC_compress_generic

static int LZ4HC_compress_generic(LZ4HC_CCtx_internal const ctx, const char const src, char const dst, int const srcSizePtr, const int dstCapacity, int cLevel, limitedOutput_directive limit)

Defined at lz4hc.c#1580

LZ4_streamHC_t_alignment

static size_t LZ4_streamHC_t_alignment()

Defined at lz4hc.c#1596

LZ4F_updateDict

static void LZ4F_updateDict(LZ4F_dctx * dctx, const BYTE * dstPtr, size_t dstSize, const BYTE * dstBufferStart, unsigned int withinTmp)

Defined at lz4frame.c#1610

LZ4F_updateDict() : only used for LZ4F_blockLinked mode Condition : != NULL

fat_dir_next

int fat_dir_next(struct fat32fs_ctx * ctx, Dir * dir)

Defined at fat.c#1615

------------------------------------------------------------------------------ Advances the directory pointer. Returns EOF when the EOF marker is hit. The user should not call this after that point. Call rewind to reset the directory pointer to the beginning.

fat_dir_rewind

int fat_dir_rewind(struct fat32fs_ctx * ctx, Dir * dir)

Defined at fat.c#1625

------------------------------------------------------------------------------ Sets dir to point to the first entry in the directory.

fat_get_error

const char * fat_get_error(int err)

Defined at fat.c#1634


fat_get_timestamp

void fat_get_timestamp(Timestamp * ts)

Defined at fat.c#1650

------------------------------------------------------------------------------ Override this function if it is needed. It is declared weak.

LZ4_compress_destSize_extState_internal

static int LZ4_compress_destSize_extState_internal(LZ4_stream_t * state, const char * src, char * dst, int * srcSizePtr, int targetDstSize, int acceleration)

Defined at lz4.c#1653

Note!: This function leaves the stream in an unclean/broken state! It is not safe to subsequently use the same state with a _fastReset() or _continue() call without resetting it.

fat_format

int fat_format(struct fat32fs_ctx * ctx, uint32_t sector_count)

Defined at fat.c#1660

vsnprintf_impl

static int vsnprintf_impl(output_gadget_t * output, const char * format, va_list args)

Defined at printf.c#1680

internal vsnprintf - used for implementing _all library functions

LZ4_initStreamHC

LZ4_streamHC_t * LZ4_initStreamHC(void * buffer, size_t size)

Defined at lz4hc.c#1693

LZ4_initStreamHC() : v1.9.0+ Required before first use of a statically allocated LZ4_streamHC_t. Before v1.9.0 : use LZ4_resetStreamHC() instead

LZ4_compress_destSize

int LZ4_compress_destSize(const char * src, char * dst, int * srcSizePtr, int targetDstSize)

Defined at lz4.c#1688

LZ4_compress_destSize() : Reverse the logic : compresses as much data as possible from 'src' buffer into already allocated buffer 'dst', of size >= 'dstCapacity'. This function either compresses the entire 'src' content into 'dst' if it's large enough, or fill 'dst' buffer completely with as much data as possible from 'src'. note: acceleration parameter is fixed to "default".

*srcSizePtr : in+out parameter. Initially contains size of input. Will be modified to indicate how many bytes where read from 'src' to fill 'dst'. New value is necessarily <= input value.

return : Nb bytes written into 'dst' (necessarily <= dstCapacity) or 0 if compression fails.

Note : 'targetDstSize' must be >= 1, because it's the smallest valid lz4 payload.

Note 2:from v1.8.2 to v1.9.1, this function had a bug (fixed in v1.9.2+): the produced compressed content could, in rare circumstances, require to be decompressed into a destination buffer larger by at least 1 byte than decompressesSize. If an application uses LZ4_compress_destSize(), it's highly recommended to update liblz4 to v1.9.2 or better. If this can't be done or ensured, the receiving decompression function should provide a dstCapacity which is > decompressedSize, by at least 1 byte. See https://github.com/lz4/lz4/issues/859 for details

vprintf

int vprintf(const char * format, va_list arg)

Defined at printf.c#1698

===========================================================================

vsnprintf

int vsnprintf(char * s, size_t n, const char * format, va_list arg)

Defined at printf.c#1704

vsprintf

int vsprintf(char * s, const char * format, va_list arg)

Defined at printf.c#1710

LZ4_createStream

LZ4_stream_t * LZ4_createStream()

Defined at lz4.c#1713

LZ4_freeStream

int LZ4_freeStream(LZ4_stream_t * streamPtr)

Defined at lz4.c#1767

LZ4_resetStreamHC

void LZ4_resetStreamHC(LZ4_streamHC_t * streamHCPtr, int compressionLevel)

Defined at lz4hc.c#1714

LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC(). The intention is to emphasize the difference with LZ4_resetStreamHC_fast(), which is now the recommended function to start a new stream of blocks, but cannot be used to initialize a memory segment containing arbitrary garbage data.

It is recommended to switch to LZ4_initStreamHC(). LZ4_resetStreamHC() will generate deprecation warnings in a future version.

just a stub

LZ4F_compressEnd

size_t LZ4F_compressEnd(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t * cOptPtr)

Defined at lz4frame.c#1255

LZ4F_compressEnd() : To properly finish an LZ4 frame, invoke LZ4F_compressEnd(). It will flush whatever data remained within cctx (like LZ4_flush()) and properly finalize the frame, with an endMark and a checksum. cOptPtr is optional : NULL can be provided, in which case all options will be set to default.

return : nb of bytes written into dstBuffer, necessarily >= 4 (endMark), or an error code if it fails (which can be tested using LZ4F_isError()) Note : LZ4F_compressEnd() is guaranteed to be successful when dstCapacity >= LZ4F_compressBound(0, prefsPtr). A successful call to LZ4F_compressEnd() makes cctx available again for another compression task.

LZ4F_compressEnd() : When you want to properly finish the compressed frame, just call LZ4F_compressEnd(). It will flush whatever data remained within compressionContext (like LZ4_flush()) but also properly finalize the frame, with an endMark and an (optional) checksum. LZ4F_compressOptions_t structure is optional : you can provide NULL as argument.

return: the number of bytes written into dstBuffer (necessarily >= 4 (endMark size)) or an error code if it fails (can be tested using LZ4F_isError()) The context can then be used again to compress a new frame, starting with LZ4F_compressBegin().

LZ4_resetStream_fast

void LZ4_resetStream_fast(LZ4_stream_t * streamPtr)

Defined at lz4.c#1761

LZ4_resetStream_fast() : v1.9.0+ Use this to prepare an LZ4_stream_t for a new chain of dependent blocks (e.g., LZ4_compress_fast_continue()).

An LZ4_stream_t must be initialized once before usage. This is automatically done when created by LZ4_createStream(). However, should the LZ4_stream_t be simply declared on stack (for example), it's necessary to initialize it first, using LZ4_initStream().

After init, start any new stream with LZ4_resetStream_fast(). A same LZ4_stream_t can be re-used multiple times consecutively and compress multiple streams, provided that it starts each new stream with LZ4_resetStream_fast().

LZ4_resetStream_fast() is much faster than LZ4_initStream(), but is not compatible with memory regions containing garbage data.

Note: it's only useful to call LZ4_resetStream_fast() in the context of streaming compression. The extState functions perform their own resets. Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive.

LZ4_loadDict

int LZ4_loadDict(LZ4_stream_t * streamPtr, const char * dictionary, int dictSize)

Defined at lz4.c#1843

LZ4_loadDict() : Use this function to reference a static dictionary into LZ4_stream_t. The dictionary must remain available during compression. LZ4_loadDict() triggers a reset, so any previous data will be forgotten. The same dictionary will have to be loaded on decompression side for successful decoding. Dictionary are useful for better compression of small data (KB range). While LZ4 itself accepts any input as dictionary, dictionary efficiency is also a topic. When in doubt, employ the Zstandard's Dictionary Builder. Loading a size of 0 is allowed, and is the same as reset.

return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded)

LZ4_loadDictSlow

int LZ4_loadDictSlow(LZ4_stream_t * streamPtr, const char * dictionary, int dictSize)

Defined at lz4.c#1848

LZ4_loadDictSlow() : v1.10.0+ Same as LZ4_loadDict(), but uses a bit more cpu to reference the dictionary content more thoroughly. This is expected to slightly improve compression ratio. The extra-cpu cost is likely worth it if the dictionary is re-used across multiple sessions.

return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded)

LZ4_setCompressionLevel

void LZ4_setCompressionLevel(LZ4_streamHC_t * LZ4_streamHCPtr, int compressionLevel)

Defined at lz4hc.c#1736

LZ4_setCompressionLevel() : v1.8.0+ (experimental) It's possible to change compression level between successive invocations of LZ4_compress_HC_continue*() for dynamic adaptation.

LZ4F_createDecompressionContext

LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx ** dctxPtr, unsigned int version)

Defined at lz4frame.c#1353

LZ4F_createDecompressionContext() : Create a decompressionContext object, which will track all decompression operations. Provides a pointer to a fully allocated and initialized LZ4F_decompressionContext object. Object can later be released using LZ4F_freeDecompressionContext().

return : if != 0, there was an error during context creation.

LZ4F_createDecompressionContext() : Create an LZ4F_dctx object, to track all decompression operations.

version provided MUST be LZ4F_VERSION. MUST be valid. The function fills with the value of a pointer to an allocated and initialized LZ4F_dctx object. The

return is an errorCode, which can be tested using LZ4F_isError(). dctx memory can be released using LZ4F_freeDecompressionContext(); Result of LZ4F_freeDecompressionContext() indicates current state of decompressionContext when being released. That is, it should be == 0 if decompression has been completed fully and correctly.

LZ4F_freeDecompressionContext

LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx * dctx)

Defined at lz4frame.c#1367

LZ4_favorDecompressionSpeed

void LZ4_favorDecompressionSpeed(LZ4_streamHC_t * LZ4_streamHCPtr, int favor)

Defined at lz4hc.c#1746

LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental) Opt. Parser will favor decompression speed over compression ratio. Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN.

LZ4F_headerSize

size_t LZ4F_headerSize(const void * src, size_t srcSize)

Defined at lz4frame.c#1515

LZ4F_headerSize() :

return : size of frame header or an error code, which can be tested using LZ4F_isError()

LZ4F_headerSize() : v1.9.0+ Provide the header size of a frame starting at src. srcSize must be >= LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH, which is enough to decode the header length.

return : size of frame header or an error code, which can be tested using LZ4F_isError() note : Frame header size is variable, but is guaranteed to be >= LZ4F_HEADER_SIZE_MIN bytes, and <= LZ4F_HEADER_SIZE_MAX bytes.

LZ4_attach_dictionary

void LZ4_attach_dictionary(LZ4_stream_t * workingStream, const LZ4_stream_t * dictionaryStream)

Defined at lz4.c#1853

LZ4_attach_dictionary() : stable since v1.10.0

This allows efficient re-use of a static dictionary multiple times.

Rather than re-loading the dictionary buffer into a working context before each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a working LZ4_stream_t, this function introduces a no-copy setup mechanism, in which the working stream references in-place.

Several assumptions are made about the state of . Currently, only states which have been prepared by LZ4_loadDict() or LZ4_loadDictSlow() should be expected to work.

Alternatively, the provided may be NULL, in which case any existing dictionary stream is unset.

If a dictionary is provided, it replaces any pre-existing stream history. The dictionary contents are the only history that can be referenced and logically immediately precede the data compressed in the first subsequent compression call.

The dictionary will only remain attached to the working stream through the first compression call, at the end of which it is cleared. stream (and source buffer) must remain in-place / accessible / unchanged through the completion of the compression session.

Note: there is no equivalent LZ4_attach_*() method on the decompression side because there is no initialization cost, hence no need to share the cost across multiple sessions. To decompress LZ4 blocks using dictionary, attached or not, just employ the regular LZ4_setStreamDecode() for streaming, or the stateless LZ4_decompress_safe_usingDict() for one-shot decompression.

LZ4_compress_HC_extStateHC_fastReset

int LZ4_compress_HC_extStateHC_fastReset(void * state, const char * src, char * dst, int srcSize, int dstCapacity, int compressionLevel)

Defined at lz4hc.c#1611

LZ4_compress_HC_extStateHC_fastReset() : A variant of LZ4_compress_HC_extStateHC().

Using this variant avoids an expensive initialization step. It is only safe to call if the state buffer is known to be correctly initialized already (see above comment on LZ4_resetStreamHC_fast() for a definition of "correctly initialized"). From a high level, the difference is that this function initializes the provided state with a call to LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a call to LZ4_resetStreamHC().

state is presumed correctly initialized, in which case its size and alignment have already been validate

LZ4_compress_fast_continue

int LZ4_compress_fast_continue(LZ4_stream_t * streamPtr, const char * src, char * dst, int srcSize, int dstCapacity, int acceleration)

Defined at lz4.c#1904

LZ4_compress_fast_continue() : Compress 'src' content using data from previously compressed blocks, for better compression ratio. 'dst' buffer must be already allocated. If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.

return : size of compressed block or 0 if there is an error (typically, cannot fit into 'dst').

Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block. Each block has precise boundaries. Each block must be decompressed separately, calling LZ4_decompress_() with relevant metadata. It's not possible to append blocks together and expect a single invocation of LZ4_decompress_() to decompress them together.

Note 2 : The previous 64KB of source data is assumed to remain present, unmodified, at same address in memory !

Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB. Make sure that buffers are separated, by at least one byte. This construction ensures that each block only depends on previous block.

Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB.

Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.

LZ4F_getFrameInfo

size_t LZ4F_getFrameInfo(LZ4F_dctx * dctx, LZ4F_frameInfo_t * frameInfoPtr, const void * srcBuffer, size_t * srcSizePtr)

Defined at lz4frame.c#1560

LZ4F_getFrameInfo() : This function extracts frame parameters (max blockSize, dictID, etc.). Its usage is optional: user can also invoke LZ4F_decompress() directly.

Extracted information will fill an existing LZ4F_frameInfo_t structure. This can be useful for allocation and dictionary identification purposes.

LZ4F_getFrameInfo() can work in the following situations :

1) At the beginning of a new frame, before any invocation of LZ4F_decompress(). It will decode header from srcBuffer, consuming the header and starting the decoding process.

 Input size must be large enough to contain the full frame header.     Frame header size can be known beforehand by LZ4F_headerSize().     Frame header size is variable, but is guaranteed to be >= LZ4F_HEADER_SIZE_MIN bytes,     and not more than <= LZ4F_HEADER_SIZE_MAX bytes.     Hence, blindly providing LZ4F_HEADER_SIZE_MAX bytes or more will always work.     It's allowed to provide more input data than the header size,     LZ4F_getFrameInfo() will only consume the header.

 If input size is not large enough,     aka if it's smaller than header size,     function will fail and return an error code.

2) After decoding has been started, it's possible to invoke LZ4F_getFrameInfo() anytime to extract already decoded frame parameters stored within dctx.

 Note that, if decoding has barely started,     and not yet read enough information to decode the header,     LZ4F_getFrameInfo() will fail.

The number of bytes consumed from srcBuffer will be updated in srcSizePtr (necessarily <= original value). LZ4F_getFrameInfo() only consumes bytes when decoding has not yet started, and when decoding the header has been successful. Decompression must then resume from (srcBuffer + srcSizePtr).

return : a hint about how many srcSize bytes LZ4F_decompress() expects for next call, or an error code which can be tested using LZ4F_isError(). note 1 : in case of error, dctx is not modified. Decoding operation can resume from beginning safely. note 2 : frame parameters are copied into an already allocated LZ4F_frameInfo_t structure.

LZ4F_getFrameInfo() : This function extracts frame parameters (max blockSize, frame checksum, etc.). Usage is optional. Objective is to provide relevant information for allocation purposes. This function works in 2 situations : - At the beginning of a new frame, in which case it will decode this information from srcBuffer, and start the decoding process. Amount of input data provided must be large enough to successfully decode the frame header. A header size is variable, but is guaranteed to be <= LZ4F_HEADER_SIZE_MAX bytes. It's possible to provide more input data than this minimum. - After decoding has been started. In which case, no input is read, frame parameters are extracted from dctx. The number of bytes consumed from srcBuffer will be updated within srcSizePtr (necessarily <= original value). Decompression must resume from (srcBuffer + srcSizePtr).

return : an hint about how many srcSize bytes LZ4F_decompress() expects for next call, or an error code which can be tested using LZ4F_isError() note 1 : in case of error, dctx is not modified. Decoding operations can resume from where they stopped. note 2 : frame parameters are copied into an already allocated LZ4F_frameInfo_t structure.

LZ4F_decompress

size_t LZ4F_decompress(LZ4F_dctx * dctx, void * dstBuffer, size_t * dstSizePtr, const void * srcBuffer, size_t * srcSizePtr, const LZ4F_decompressOptions_t * dOptPtr)

Defined at lz4frame.c#1705

brief Incrementally decompresses an LZ4 frame into user-provided buffers.

Call repeatedly until the return value is 0 (frame fully decoded) or an error is reported. On each call, the function consumes up to srcSizePtr bytes from p and produces up to dstSizePtr bytes into p It updates both size pointers with the actual number of bytes consumed/produced. There is no separate flush step.

Typical loop: - Provide whatever input you have and an available output buffer. - Read how much input was consumed and how much output was produced. - Use the returned value as a hint for how many source bytes are ideal next time.

dctx [in] A valid decompression context created by LZ4F_createDecompressionContext().

dstBuffer [out] Destination buffer for decompressed bytes. May change between calls.

dstSizePtr [in,out] In: capacity of p in bytes. Out: number of bytes written (<= input value).

srcBuffer [in] Source buffer containing (more) compressed data. May point to the middle of a larger buffer.

srcSizePtr [in,out] In: number of available bytes in p Out: number of bytes consumed (<= input value).

optionsPtr [in] Optional decompression options; pass NULL for defaults.

return See

retval

retval Hint (in bytes) for how many source bytes are ideal to provide on the next call. This also indicates the current frame is not yet complete: the decompressor expects more input, or may require additional output space to make progress. User can always pass any amount of input; this value is only a performance hint.

retval The current frame is fully decoded. If *srcSizePtr is less than the provided value, the unconsumed tail is the start of another frame (if any).

retval An error code; test with LZ4F_isError(ret). After an error, dctx is not resumable: call LZ4F_resetDecompressionContext() before reusing it.

prep is a valid state created by LZ4F_createDecompressionContext().

post srcSizePtr and dstSizePtr are updated with the actual bytes consumed/produced.p contents in [0, *dstSizePtr) are valid decompressed data.

note The function may not consume all provided input on each call. Always check *srcSizePtr. Present any unconsumed source bytes again on the next call.

notep content is overwritten; it does not need to be stable across calls.

note After finishing a frame (return==0), you may immediately start feeding the next frame into the same p (optionally, one can use LZ4F_resetDecompressionContext()).

warning If you called LZ4F_getFrameInfo() beforehand, you must advance p and decrease *srcSizePtr by the number of bytes it consumed (the frame header). Failing to do so can cause decompression failure or, worse, silent corruption.

see LZ4F_getFrameInfo(), LZ4F_isError(), LZ4F_resetDecompressionContext(), LZ4F_createDecompressionContext(), LZ4F_freeDecompressionContext()

LZ4F_decompress() : Call this function repetitively to regenerate compressed data in srcBuffer. The function will attempt to decode up to srcSizePtr bytes from srcBuffer into dstBuffer of capacity dstSizePtr.

The number of bytes regenerated into dstBuffer will be provided within *dstSizePtr (necessarily<= original value).

The number of bytes effectively read from srcBuffer will be provided within *srcSizePtr (necessarily <= original value). If number of bytes read is < number of bytes provided, then decompression operation is not complete. Remaining data will have to be presented again in a subsequent invocation.

The function result is an hint of the better srcSize to use for next call to LZ4F_decompress. Schematically, it's the size of the current (or remaining) compressed block + header of next block. Respecting the hint provides a small boost to performance, since it allows less buffer shuffling. Note that this is just a hint, and it's always possible to any srcSize value. When a frame is fully decoded,

return will be 0. If decompression failed,

return is an error code which can be tested using LZ4F_isError().

LZ4F_resetDecompressionContext

void LZ4F_resetDecompressionContext(LZ4F_dctx * dctx)

Defined at lz4frame.c#1390

LZ4F_resetDecompressionContext() : added in v1.8.0 In case of an error, the context is left in "undefined" state. In which case, it's necessary to reset it, before re-using it. This method can also be used to abruptly stop any unfinished decompression, and start a new one using same context resources.

==--- Streaming Decompression operations ---==

LZ4_compress_fast_extState_fastReset

int LZ4_compress_fast_extState_fastReset(void * state, const char * src, char * dst, int srcSize, int dstCapacity, int acceleration)

Defined at lz4.c#1574

LZ4_compress_fast_extState_fastReset() : A variant of LZ4_compress_fast_extState().

Using this variant avoids an expensive initialization step. It is only safe to call if the state buffer is known to be correctly initialized already (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized"). From a high level, the difference is that this function initializes the provided state with a call to something like LZ4_resetStream_fast() while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().

LZ4_compress_fast_extState_fastReset() : A variant of LZ4_compress_fast_extState().

Using this variant avoids an expensive initialization step. It is only safe to call if the state buffer is known to be correctly initialized already (see comment in lz4.h on LZ4_resetStream_fast() for a definition of "correctly initialized").

LZ4_compress_destSize_extState

int LZ4_compress_destSize_extState(void * state, const char * src, char * dst, int * srcSizePtr, int targetDstSize, int acceleration)

Defined at lz4.c#1678

LZ4_compress_destSize_extState() : introduced in v1.10.0 Same as LZ4_compress_destSize(), but using an externally allocated state. Also: exposes

LZ4F_uncompressedUpdate

size_t LZ4F_uncompressedUpdate(LZ4F_cctx * cctx, void * dstBuffer, size_t dstCapacity, const void * srcBuffer, size_t srcSize, const LZ4F_compressOptions_t * cOptPtr)

Defined at lz4frame.c#1192

LZ4F_uncompressedUpdate() : LZ4F_uncompressedUpdate() can be called repetitively to add data stored as uncompressed blocks. Important rule: dstCapacity MUST be large enough to store the entire source buffer as no compression is done for this operation If this condition is not respected, LZ4F_uncompressedUpdate() will fail (result is an errorCode). After an error, the state is left in a UB state, and must be re-initialized or freed. If previously a compressed block was written, buffered data is flushed first, before appending uncompressed data is continued. This operation is only supported when LZ4F_blockIndependent is used. cOptPtr is optional : NULL can be provided, in which case all options are set to default.

return : number of bytes written into dstBuffer (it can be zero, meaning input data was just buffered). or an error code if it fails (which can be tested using LZ4F_isError())

LZ4F_uncompressedUpdate() : Same as LZ4F_compressUpdate(), but requests blocks to be sent uncompressed. This symbol is only supported when LZ4F_blockIndependent is used MUST be >= LZ4F_compressBound(srcSize, preferencesPtr). is optional : provide NULL to mean "default".

return : the number of bytes written into dstBuffer. It can be zero, meaning input data was just buffered. or an error code if it fails (which can be tested using LZ4F_isError()) After an error, the state is left in a UB state, and must be re-initialized.

LZ4F_createDecompressionContext_advanced

LZ4F_dctx * LZ4F_createDecompressionContext_advanced(LZ4F_CustomMem customMem, unsigned int version)

Defined at lz4frame.c#1336

LZ4F_dctx_size

size_t LZ4F_dctx_size(const LZ4F_dctx * dctx)

Defined at lz4frame.c#1379

vfctprintf

int vfctprintf(void ()(char, void ) out, void * extra_arg, const char * format, va_list arg)

Defined at printf.c#1715

printf

int printf(const char * format)

Defined at printf.c#1725

LZ4_stream_t_alignment

static size_t LZ4_stream_t_alignment()

Defined at lz4.c#1725

sprintf

int sprintf(char * s, const char * format)

Defined at printf.c#1735

LZ4_initStream

LZ4_stream_t * LZ4_initStream(void * stateBuffer, size_t size)

Defined at lz4.c#1738

LZ4_initStream() : v1.9.0+ An LZ4_stream_t structure must be initialized at least once. This is automatically done when invoking LZ4_createStream(), but it's not when the structure is simply declared on stack (for example).

Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t. It can also initialize any arbitrary buffer of sufficient size, and will

return a pointer of proper type upon initialization.

Note : initialization fails if size and alignment conditions are not respected. In which case, the function will

return NULL. Note2: An LZ4_stream_t structure guarantees correct alignment and size. Note3: Before v1.9.0, use LZ4_resetStream() instead

snprintf

int snprintf(char * s, size_t n, const char * format)

Defined at printf.c#1745

LZ4_resetStream

void LZ4_resetStream(LZ4_stream_t * streamPtr)

Defined at lz4.c#1755

LZ4_resetStream() : An LZ4_stream_t structure must be initialized at least once. This is done with LZ4_initStream(), or LZ4_resetStream(). Consider switching to LZ4_initStream(), invoking LZ4_resetStream() will trigger deprecation warnings in the future.

resetStream is now deprecated, prefer initStream() which is more general

fctprintf

int fctprintf(void ()(char, void ) out, void * extra_arg, const char * format)

Defined at printf.c#1755

putchar_

void putchar_(char ch)

Defined at printf.c#1765

LZ4_loadDict_internal

static int LZ4_loadDict_internal(LZ4_stream_t * LZ4_dict, const char * dictionary, int dictSize, LoadDict_mode_e _ld)

Defined at lz4.c#1779

LZ4HC_setExternalDict

static void LZ4HC_setExternalDict(LZ4HC_CCtx_internal * ctxPtr, const BYTE * newBlock)

Defined at lz4hc.c#1792

compression

LZ4_compressHC_continue_generic

static int LZ4_compressHC_continue_generic(LZ4_streamHC_t * LZ4_streamHCPtr, const char * src, char * dst, int * srcSizePtr, int dstCapacity, limitedOutput_directive limit)

Defined at lz4hc.c#1812

LZ4_renormDictT

static void LZ4_renormDictT(LZ4_stream_t_internal * LZ4_dict, int nextSize)

Defined at lz4.c#1881

LZ4HC_literalsPrice

static int LZ4HC_literalsPrice(const int litlen)

Defined at lz4hc.c#1921

price in bytes

LZ4HC_sequencePrice

static int LZ4HC_sequencePrice(int litlen, int mlen)

Defined at lz4hc.c#1931

requires mlen >= MINMATCH

LZ4HC_FindLongerMatch

static LZ4HC_match_t LZ4HC_FindLongerMatch(LZ4HC_CCtx_internal const ctx, const BYTE * ip, const BYTE const iHighLimit, int minLen, int nbSearches, const dictCtx_directive dict, const HCfavor_e favorDecSpeed)

Defined at lz4hc.c#1945

read_long_length_no_check

static size_t read_long_length_no_check(const BYTE ** pp)

Defined at lz4.c#2073

variant for decompress_unsafe() does not know end of input presumes input is well formed note : will consume at least one byte

LZ4_decompress_unsafe_generic

static int LZ4_decompress_unsafe_generic(const BYTE const istart, BYTE const ostart, int decompressedSize, size_t prefixSize, const BYTE const dictStart, const size_t dictSize)*

Defined at lz4.c#2094

core decoder variant for LZ4_decompress_fast*() for legacy support only : these entry points are deprecated. - Presumes input is correctly formed (no defense vs malformed inputs) - Does not know input size (presume input buffer is "large enough") - Decompress a full block (only)

return : nb of bytes read from input. Note : this variant is not optimized for speed, just for maintenance. the goal is to remove support of decompress_fast*() variants by v2.0

read_variable_length

static Rvl_t read_variable_length(const BYTE ** ip, const BYTE * ilimit, int initial_check)

Defined at lz4.c#2209

LZ4_decompress_generic

static int LZ4_decompress_generic(const char const src, char const dst, int srcSize, int outputSize, earlyEnd_directive partialDecoding, dict_directive dict, const BYTE const lowPrefix, const BYTE const dictStart, const size_t dictSize)

Defined at lz4.c#2252

LZ4_decompress_generic() : This generic decompression function covers all use cases. It shall be instantiated several times, using different sets of directives. Note that it is important for performance that this function really get inlined, in order to remove useless branches during compilation optimization.

LZ4_compressHC

int LZ4_compressHC(const char * source, char * dest, int inputSize)

Defined at lz4hc.c#2329

Wrappers for deprecated compression functions

deprecated compression functions

LZ4_compressHC_limitedOutput

int LZ4_compressHC_limitedOutput(const char * source, char * dest, int inputSize, int maxOutputSize)

Defined at lz4hc.c#2333

LZ4_compressHC2

int LZ4_compressHC2(const char * source, char * dest, int inputSize, int compressionLevel)

Defined at lz4hc.c#2337

LZ4_compressHC2_limitedOutput

int LZ4_compressHC2_limitedOutput(const char * source, char * dest, int inputSize, int maxOutputSize, int compressionLevel)

Defined at lz4hc.c#2341

LZ4_compressHC_withStateHC

int LZ4_compressHC_withStateHC(void * state, const char * source, char * dest, int inputSize)

Defined at lz4hc.c#2345

LZ4_compressHC_limitedOutput_withStateHC

int LZ4_compressHC_limitedOutput_withStateHC(void * state, const char * source, char * dest, int inputSize, int maxOutputSize)

Defined at lz4hc.c#2349

LZ4_compressHC2_withStateHC

int LZ4_compressHC2_withStateHC(void * state, const char * source, char * dest, int inputSize, int compressionLevel)

Defined at lz4hc.c#2354

LZ4_compressHC2_limitedOutput_withStateHC

int LZ4_compressHC2_limitedOutput_withStateHC(void * state, const char * source, char * dest, int inputSize, int maxOutputSize, int compressionLevel)

Defined at lz4hc.c#2358

LZ4_compressHC_continue

int LZ4_compressHC_continue(LZ4_streamHC_t * LZ4_streamHCPtr, const char * source, char * dest, int inputSize)

Defined at lz4hc.c#2363

segment_holding

static msegmentptr segment_holding(mstate m, char * addr)

Defined at malloc.c#2711

Return segment holding given address

static int has_segment_link(mstate m, msegmentptr ss)

Defined at malloc.c#2722

Return true if segment contains a segment link

malloc_inspect_all

void malloc_inspect_all(void ()(void , void , size_t, void ) handler, void * arg)

malloc_inspect_all(void(handler)(void start, void end, size_t used_bytes, void callback_arg), void* arg); Traverses the heap and calls the given handler for each managed region, skipping all bytes that are (or may be) used for bookkeeping purposes. Traversal does not include include chunks that have been directly memory mapped. Each reported region begins at the start address, and continues up to but not including the end address. The first used_bytes of the region contain allocated data. If used_bytes is zero, the region is unallocated. The handler is invoked with the given callback argument. If locks are defined, they are held during the entire traversal. It is a bad idea to invoke other malloc functions from within the handler.

For example, to count the number of in-use chunks with size greater than 1000, you could write: static int count = 0; void count_chunks(void start, void end, size_t used, void* arg) { if (used >= 1000) ++count; } then: malloc_inspect_all(count_chunks, NULL);

malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined.

LZ4_decompress_safe_partial

int LZ4_decompress_safe_partial(const char * src, char * dst, int srcSize, int targetOutputSize, int dstCapacity)

Defined at lz4.c#2741

LZ4_decompress_safe_partial() : Decompress an LZ4 compressed block, of size 'srcSize' at position 'src', into destination buffer 'dst' of size 'dstCapacity'. Up to 'targetOutputSize' bytes will be decoded. The function stops decoding on reaching this objective. This can be useful to boost performance whenever only the beginning of a block is required.

return : the number of bytes decoded in dst (necessarily <= targetOutputSize) If source stream is detected malformed, function returns a negative result.

Note 1 :

return can be < targetOutputSize, if compressed block contains less data.

Note 2 : targetOutputSize must be <= dstCapacity

Note 3 : this function effectively stops decoding on reaching targetOutputSize, so dstCapacity is kind of redundant. This is because in older versions of this function, decoding operation would still write complete sequences. Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize, it could write more bytes, though only up to dstCapacity. Some "margin" used to be required for this operation to work properly. Thankfully, this is no longer necessary. The function nonetheless keeps the same signature, in an effort to preserve API compatibility.

Note 4 : If srcSize is the exact size of the block, then targetOutputSize can be any value, including larger than the block's decompressed size. The function will, at most, generate block's decompressed size.

Note 5 : If srcSize is larger than block's compressed size, then targetOutputSize MUST be <= block's decompressed size. Otherwise, silent corruption will occur.

LZ4_compressHC_limitedOutput_continue

int LZ4_compressHC_limitedOutput_continue(LZ4_streamHC_t * LZ4_streamHCPtr, const char * source, char * dest, int inputSize, int maxOutputSize)

Defined at lz4hc.c#2367

LZ4_createHC

void * LZ4_createHC(const char * inputBuffer)

Defined at lz4hc.c#2391

LZ4_freeHC

int LZ4_freeHC(void * LZ4HC_Data)

Defined at lz4hc.c#2400

LZ4_slideInputBufferHC

char * LZ4_slideInputBufferHC(void * LZ4HC_Data)

Defined at lz4hc.c#2422

LZ4_compressHC2_continue

int LZ4_compressHC2_continue(void * LZ4HC_Data, const char * source, char * dest, int inputSize, int compressionLevel)

Defined at lz4hc.c#2409

LZ4_compressHC2_limitedOutput_continue

int LZ4_compressHC2_limitedOutput_continue(void * LZ4HC_Data, const char * source, char * dest, int inputSize, int maxOutputSize, int compressionLevel)

Defined at lz4hc.c#2415

LZ4_sizeofStreamStateHC

int LZ4_sizeofStreamStateHC()

Defined at lz4hc.c#2374

Deprecated streaming functions

LZ4_resetStreamStateHC

int LZ4_resetStreamStateHC(void * state, char * inputBuffer)

Defined at lz4hc.c#2381

state is presumed correctly sized, aka >= sizeof(LZ4_streamHC_t)

return : 0 on success, !=0 if error

LZ4_saveDict

int LZ4_saveDict(LZ4_stream_t * streamPtr, char * safeBuffer, int maxDictSize)

Defined at lz4.c#2033

LZ4_saveDict() : If last 64KB data cannot be guaranteed to remain available at its current memory location, save it into a safer place (char* safeBuffer). This is schematically equivalent to a memcpy() followed by LZ4_loadDict(), but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.

return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error.

LZ4_saveDict() : If previously compressed data block is not guaranteed to remain available at its memory location, save it into a safer place (char* safeBuffer). Note : no need to call LZ4_loadDict() afterwards, dictionary is immediately usable, one can therefore call LZ4_compress_fast_continue() right after.

return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error.

LZ4_decompress_safe_partial_withPrefix64k

static int LZ4_decompress_safe_partial_withPrefix64k(const char * source, char * dest, int compressedSize, int targetOutputSize, int dstCapacity)

Defined at lz4.c#2767

LZ4_decompress_safe_withSmallPrefix

static int LZ4_decompress_safe_withSmallPrefix(const char * source, char * dest, int compressedSize, int maxOutputSize, size_t prefixSize)

Defined at lz4.c#2783

LZ4_decompress_safe_partial_withSmallPrefix

static int LZ4_decompress_safe_partial_withSmallPrefix(const char * source, char * dest, int compressedSize, int targetOutputSize, int dstCapacity, size_t prefixSize)

Defined at lz4.c#2791

LZ4_decompress_fast_extDict

static int LZ4_decompress_fast_extDict(const char * source, char * dest, int originalSize, const void * dictStart, size_t dictSize)

Defined at lz4.c#2820

LZ4_decompress_safe_doubleDict

static int LZ4_decompress_safe_doubleDict(const char * source, char * dest, int compressedSize, int maxOutputSize, size_t prefixSize, const void * dictStart, size_t dictSize)

Defined at lz4.c#2831

The "double dictionary" mode, for use with e.g. ring buffers: the first part of the dictionary is passed as prefix, and the second via dictStart + dictSize. These routines are used only once, in LZ4_decompress_*_continue().

LZ4_createStreamDecode

LZ4_streamDecode_t * LZ4_createStreamDecode()

Defined at lz4.c#2844

LZ4_freeStreamDecode

int LZ4_freeStreamDecode(LZ4_streamDecode_t * LZ4_stream)

Defined at lz4.c#2850

LZ4_setStreamDecode

int LZ4_setStreamDecode(LZ4_streamDecode_t * LZ4_streamDecode, const char * dictionary, int dictSize)

Defined at lz4.c#2866

LZ4_setStreamDecode() : An LZ4_streamDecode_t context can be allocated once and re-used multiple times. Use this function to start decompression of a new stream of blocks. A dictionary can optionally be set. Use NULL or size 0 for a reset order. Dictionary is presumed stable : it must remain accessible and unmodified during next decompression.

return : 1 if OK, 0 if error

LZ4_setStreamDecode() : Use this function to instruct where to find the dictionary. This function is not necessary if previous data is still available where it was decoded. Loading a size of 0 is allowed (same effect as no dictionary).

return : 1 if OK, 0 if error

malloc_stats

void malloc_stats()

malloc_stats(); Prints on stderr the amount of space obtained from the system (both via sbrk and mmap), the maximum amount (which may be more than current if malloc_trim and/or munmap got called), and the current number of bytes allocated via malloc (or realloc, etc) but not yet freed. Note that this is the number of bytes allocated, not the number requested. It will be larger than the number requested because of alignment and bookkeeping overhead. Because it includes alignment wastage as being in use, this figure may be greater than zero even when no user-level chunks are allocated.

The reported current and maximum system memory can be inaccurate if a program makes other calls to system memory allocation functions (normally sbrk) outside of malloc.

malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo.

malloc_stats(); Prints on stderr the amount of space obtained from the system (both via sbrk and mmap), the maximum amount (which may be more than current if malloc_trim and/or munmap got called), and the current number of bytes allocated via malloc (or realloc, etc) but not yet freed. Note that this is the number of bytes allocated, not the number requested. It will be larger than the number requested because of alignment and bookkeeping overhead. Because it includes alignment wastage as being in use, this figure may be greater than zero even when no user-level chunks are allocated.

The reported current and maximum system memory can be inaccurate if a program makes other calls to system memory allocation functions (normally sbrk) outside of malloc.

malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo.

malloc_stats is not compiled if NO_MALLOC_STATS is defined.

LZ4_decoderRingBufferSize

int LZ4_decoderRingBufferSize(int maxBlockSize)

Defined at lz4.c#2892

LZ4_decoderRingBufferSize() : when setting a ring buffer for streaming decompression (optional scenario), provides the minimum size of this ring buffer to be compatible with any source respecting maxBlockSize condition. Note : in a ring buffer scenario, blocks are presumed decompressed next to each other. When not enough space remains for next block (remainingSize < maxBlockSize), decoding resumes from beginning of ring buffer.

return : minimum ring buffer size, or 0 if there is an error (invalid maxBlockSize).

LZ4_decoderRingBufferSize() : v1.8.2+ Note : in a ring buffer scenario (optional), blocks are presumed decompressed next to each other up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize), at which stage it resumes from beginning of ring buffer. When setting such a ring buffer for streaming decompression, provides the minimum size of this ring buffer to be compatible with any source respecting maxBlockSize condition.

return : minimum ring buffer size, or 0 if there is an error (invalid maxBlockSize).

LZ4_decompress_safe_continue

int LZ4_decompress_safe_continue(LZ4_streamDecode_t * LZ4_streamDecode, const char * src, char * dst, int srcSize, int dstCapacity)

Defined at lz4.c#2911

LZ4_decompress_safe_continue() : This decoding function allows decompression of consecutive blocks in "streaming" mode. The difference with the usual independent blocks is that new blocks are allowed to find references into former blocks. A block is an unsplittable entity, and must be presented entirely to the decompression function. LZ4_decompress_safe_continue() only accepts one block at a time. It's modeled after LZ4_decompress_safe() and behaves similarly.

_streamDecode : decompression state, tracking the position in memory of past data : exact complete size of one compressed block. : size of destination buffer (which must be already allocated), must be an upper bound of decompressed size.

return : number of bytes decompressed into destination buffer (necessarily <= dstCapacity) If destination buffer is not large enough, decoding will stop and output an error code (negative value). If the source stream is detected malformed, the function will stop decoding and return a negative result.

The last 64KB of previously decoded data must remain available and unmodified at the memory position where they were previously decoded. If less than 64KB of data has been decoded, all the data must be present.

Special : if decompression side sets a ring buffer, it must respect one of the following conditions : - Decompression buffer size is at least LZ4_decoderRingBufferSize(maxBlockSize). maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes. In which case, encoding and decoding buffers do not need to be synchronized. Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize. - Synchronized mode : Decompression buffer size is exactly the same as compression buffer size, and follows exactly same update rule (block boundaries at same positions), and decoding function is provided with exact decompressed size of each block (exception for last block of the stream), then decoding & encoding ring buffer can have any size, including small ones ( < 64 KB). - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes. In which case, encoding and decoding buffers do not need to be synchronized, and encoding ring buffer can have any size, including small ones ( < 64 KB).

Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression, then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.

_continue() : These decoding functions allow decompression of multiple blocks in "streaming" mode. Previously decoded blocks must still be available at the memory position where they weredecoded. If it's not possible, save the relevant part of decoded data into a safe buffer, andindicate where it stands using LZ4_setStreamDecode()

LZ4F_decompress_usingDict

size_t LZ4F_decompress_usingDict(LZ4F_dctx * dctxPtr, void * dstBuffer, size_t * dstSizePtr, const void * srcBuffer, size_t * srcSizePtr, const void * dict, size_t dictSize, const LZ4F_decompressOptions_t * decompressOptionsPtr)

Defined at lz4frame.c#2238

LZ4F_decompress_usingDict() : Same as LZ4F_decompress(), using a predefined dictionary. Dictionary is used "in place", without any preprocessing. It must remain accessible throughout the entire frame decoding.

LZ4F_decompress_usingDict() : stable since v1.10 Same as LZ4F_decompress(), using a predefined dictionary. Dictionary is used "in place", without any preprocessing.* It must remain accessible throughout the entire frame decoding.

LZ4_decompress_safe_usingDict

int LZ4_decompress_safe_usingDict(const char * src, char * dst, int srcSize, int dstCapacity, const char * dictStart, int dictSize)

Defined at lz4.c#3004

LZ4_decompress_safe_usingDict() : Works the same as a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue() However, it's stateless: it doesn't need any LZ4_streamDecode_t state. Dictionary is presumed stable : it must remain accessible and unmodified during decompression. Performance tip : Decompression speed can be substantially increased when dst == dictStart + dictSize.

Advanced decoding functions :_usingDict() : These decoding functions work the same as "_continue" ones, the dictionary must be explicitly provided within parameters

LZ4_decompress_safe_partial_usingDict

int LZ4_decompress_safe_partial_usingDict(const char * src, char * dst, int compressedSize, int targetOutputSize, int maxOutputSize, const char * dictStart, int dictSize)

Defined at lz4.c#3022

LZ4_decompress_safe_partial_usingDict() : Behaves the same as LZ4_decompress_safe_partial() with the added ability to specify a memory segment for past data. Performance tip : Decompression speed can be substantially increased when dst == dictStart + dictSize.

LZ4_compress_forceExtDict

int LZ4_compress_forceExtDict(LZ4_stream_t * LZ4_dict, const char * source, char * dest, int srcSize)

Defined at lz4.c#2005

Hidden debug function, to force-test external dictionary mode

LZ4_decompress_safe_forceExtDict

int LZ4_decompress_safe_forceExtDict(const char * source, char * dest, int compressedSize, int maxOutputSize, const void * dictStart, size_t dictSize)

Defined at lz4.c#2801

LZ4_decompress_safe_partial_forceExtDict

int LZ4_decompress_safe_partial_forceExtDict(const char * source, char * dest, int compressedSize, int targetOutputSize, int dstCapacity, const void * dictStart, size_t dictSize)

Defined at lz4.c#2810

LZ4_compress

int LZ4_compress(const char * src, char * dest, int srcSize)

Defined at lz4.c#3060

Obsolete compression functions (since v1.7.3)

LZ4_compress_limitedOutput

int LZ4_compress_limitedOutput(const char * src, char * dest, int srcSize, int maxOutputSize)

Defined at lz4.c#3056

=******* Obsolete Functions*******

obsolete compression functions

LZ4_compress_withState

int LZ4_compress_withState(void * state, const char * source, char * dest, int inputSize)

Defined at lz4.c#3069

LZ4_compress_limitedOutput_withState

int LZ4_compress_limitedOutput_withState(void * state, const char * source, char * dest, int inputSize, int maxOutputSize)

Defined at lz4.c#3064

LZ4_compress_continue

int LZ4_compress_continue(LZ4_stream_t * LZ4_streamPtr, const char * source, char * dest, int inputSize)

Defined at lz4.c#3078

LZ4_compress_limitedOutput_continue

int LZ4_compress_limitedOutput_continue(LZ4_stream_t * LZ4_streamPtr, const char * source, char * dest, int inputSize, int maxOutputSize)

Defined at lz4.c#3073

LZ4_uncompress

int LZ4_uncompress(const char * source, char * dest, int outputSize)

Defined at lz4.c#3090

Obsolete decompression functions (since v1.8.0)

These decompression functions are deprecated and should no longer be used.They are only provided here for compatibility with older user programs.- LZ4_uncompress is totally equivalent to LZ4_decompress_fast- LZ4_uncompress_unknownOutputSize is totally equivalent to LZ4_decompress_safe

LZ4_uncompress_unknownOutputSize

int LZ4_uncompress_unknownOutputSize(const char * source, char * dest, int isize, int maxOutputSize)

Defined at lz4.c#3094

LZ4_create

void * LZ4_create(char * inputBuffer)

Defined at lz4.c#3114

Obsolete streaming functions (since v1.7.0) degraded functionality; do not use!

In order to perform streaming compression, these functions depended on data that is no longer tracked in the state. They have been preserved as well as possible: using them will still produce a correct output. However, they don't actually retain any history between compression calls. The compression ratio achieved will therefore be no better than compressing each chunk independently.

LZ4_sizeofStreamState

int LZ4_sizeofStreamState()

Defined at lz4.c#3101

Obsolete Streaming functions

LZ4_resetStreamState

int LZ4_resetStreamState(void * state, char * inputBuffer)

Defined at lz4.c#3106

LZ4_slideInputBuffer

char * LZ4_slideInputBuffer(void * state)

Defined at lz4.c#3121

LZ4_decompress_safe_withPrefix64k

int LZ4_decompress_safe_withPrefix64k(const char * src, char * dst, int compressedSize, int maxDstSize)

Defined at lz4.c#2759

Obsolete streaming decoding functions (since v1.7.0)

LZ4_decompress_fast_withPrefix64k

int LZ4_decompress_fast_withPrefix64k(const char * src, char * dst, int originalSize)

Defined at lz4.c#2776

Another obsolete API function, paired with the previous one.

LZ4_decompress_fast

int LZ4_decompress_fast(const char * src, char * dst, int originalSize)

Defined at lz4.c#2750

Obsolete LZ4_decompress_fast variants (since v1.9.0) : These functions used to be faster than LZ4_decompress_safe(), but this is no longer the case. They are now slower. This is because LZ4_decompress_fast() doesn't know the input size, and therefore must progress more cautiously into the input buffer to not read beyond the end of block. On top of that LZ4_decompress_fast() is not protected vs malformed or malicious inputs, making it a security liability. As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated.

The last remaining LZ4_decompress_fast() specificity is that it can decompress a block without knowing its compressed size. Such functionality can be achieved in a more secure manner by employing LZ4_decompress_safe_partial().

Parameters: originalSize : is the uncompressed size to regenerate. dst must be already allocated, its size must be >= 'originalSize' bytes.

return : number of bytes read from source buffer (== compressed size). The function expects to finish at block's end exactly. If the source stream is detected malformed, the function stops decoding and returns a negative result. note : LZ4_decompress_fast() requires originalSize. Thanks to this information, it never writes past the output buffer. However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds. Also, since match offsets are not validated, match reads from 'src' may underflow too. These issues never happen if input (compressed) data is correct. But they may happen if input data is invalid (error or intentional tampering). As a consequence, use these functions in trusted environments with trusted data only*.

LZ4_decompress_fast_continue

int LZ4_decompress_fast_continue(LZ4_streamDecode_t * LZ4_streamDecode, const char * src, char * dst, int originalSize)

Defined at lz4.c#2955

LZ4_decompress_fast_usingDict

int LZ4_decompress_fast_usingDict(const char * src, char * dst, int originalSize, const char * dictStart, int dictSize)

Defined at lz4.c#3042

LZ4HC_compress_optimal

static int LZ4HC_compress_optimal(LZ4HC_CCtx_internal * ctx, const char const source, char * dst, int * srcSizePtr, int dstCapacity, const int nbSearches, size_t sufficient_len, const limitedOutput_directive limit, const int fullUpdate, const dictCtx_directive dict, const HCfavor_e favorDecSpeed)*

Defined at lz4hc.c#1972

preconditions: - *srcSizePtr within [1, LZ4_MAX_INPUT_SIZE] - src is valid - maxOutputSize >= 1 - dst is valid

init_mparams

static int init_mparams()

Defined at malloc.c#3112

Initialize mparams

change_mparam

static int change_mparam(int param_number, int value)

Defined at malloc.c#3202

support for mallopt

internal_mallinfo

static struct mallinfo internal_mallinfo(mstate m)

Defined at malloc.c#3497

mmap_alloc

static void * mmap_alloc(mstate m, size_t nb)

Defined at malloc.c#3836

Malloc using mmap

mmap_resize

static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags)

Defined at malloc.c#3868

Realloc using mmap

init_top

static void init_top(mstate m, mchunkptr p, size_t psize)

Defined at malloc.c#3906

Initialize top chunk and its size

init_bins

static void init_bins(mstate m)

Defined at malloc.c#3921

Initialize bins for a new mstate that is otherwise zeroed out

prepend_alloc

static void * prepend_alloc(mstate m, char * newbase, char * oldbase, size_t nb)

Defined at malloc.c#3950

Allocate chunk and prepend remainder with chunk in successor base.

add_segment

static void add_segment(mstate m, char * tbase, size_t tsize, flag_t mmapped)

Defined at malloc.c#3992

Add a segment to hold a new noncontiguous region

sys_alloc

static void * sys_alloc(mstate m, size_t nb)

Defined at malloc.c#4047

Get memory from system using MORECORE or MMAP

release_unused_segments

static size_t release_unused_segments(mstate m)

Defined at malloc.c#4258

Unmap and unlink any mmapped segments that don't contain used chunks

sys_trim

static int sys_trim(mstate m, size_t pad)

Defined at malloc.c#4305

dispose_chunk

static void dispose_chunk(mstate m, mchunkptr p, size_t psize)

Defined at malloc.c#4373

Consolidate and bin a chunk. Differs from exported versions of free mainly in that the chunk need not be marked as inuse.

tmalloc_large

static void * tmalloc_large(mstate m, size_t nb)

Defined at malloc.c#4444

allocate a large request from the best fitting chunk in a treebin

tmalloc_small

static void * tmalloc_small(mstate m, size_t nb)

Defined at malloc.c#4515

allocate a small request from the best fitting chunk in a treebin

malloc

void * malloc(size_t )

Defined at malloc.c#4554

malloc(size_t n) Returns a pointer to a newly allocated chunk of at least n bytes, or null if no space is available, in which case errno is set to ENOMEM on ANSI C systems.

If n is zero, malloc returns a minimum-sized chunk. (The minimum size is 16 bytes on most 32bit systems, and 32 bytes on 64bit systems.) Note that size_t is an unsigned type, so calls with arguments that would be negative if signed are interpreted as requests for huge amounts of space, which will often fail. The maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t.

free

void free(void * )

Defined at malloc.c#4692

free(void* p) Releases the chunk of memory pointed to by p, that had been previously allocated using malloc or a related routine such as realloc. It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort.

---------------------------- free ---------------------------

calloc

void * calloc(size_t , size_t )

Defined at malloc.c#4801

calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero.

try_realloc_chunk

static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, int can_move)

Defined at malloc.c#4821

Try to realloc; only in-place unless can_move true

internal_memalign

static void * internal_memalign(mstate m, size_t alignment, size_t bytes)

Defined at malloc.c#4900

ialloc

static void ** ialloc(mstate m, size_t n_elements, size_t * sizes, int opts, void [] chunks)*

Defined at malloc.c#4981

Common support for independent_X routines, handling all of the combinations that can result. The opts arg has: bit 0 set if all elements are same size (using sizes[0]) bit 1 set if elements should be zeroed

internal_bulk_free

static size_t internal_bulk_free(mstate m, void [] array, size_t nelem)*

Defined at malloc.c#5107

Try to free all pointers in the given array. Note: this could be made faster, by delaying consolidation, at the price of disabling some user integrity checks, We still optimize some consolidations by combining adjacent chunks before freeing, which will occur often if allocated with ialloc or the array is sorted.

realloc

void * realloc(void * , size_t )

Defined at malloc.c#5195

realloc(void* p, size_t n) Returns a pointer to a chunk of size n that contains the same data as does chunk p up to the minimum of (n, p's size) bytes, or null if no space is available.

The returned pointer may or may not be the same as p. The algorithm prefers extending p in most cases when possible, otherwise it employs the equivalent of a malloc-copy-free sequence.

If p is null, realloc is equivalent to malloc.

If space is not available, realloc returns null, errno is set (if on ANSI) and p is NOT freed.

if n is for fewer bytes than already held by p, the newly unused space is lopped off and freed if possible. realloc with a size argument of zero (re)allocates a minimum-sized chunk.

The old unix realloc convention of allowing the last-free'd chunk to be used as an argument to realloc is not supported.

realloc_in_place

void * realloc_in_place(void * , size_t )

Defined at malloc.c#5240

realloc_in_place(void* p, size_t n) Resizes the space allocated for p to size n, only if this can be done without moving p (i.e., only if there is adjacent space available if n is greater than p's current allocated size, or n is less than or equal to p's size). This may be used instead of plain realloc if an alternative allocation strategy is needed upon failure to expand space; for example, reallocation of a buffer that must be memory-aligned or cleared. You can use realloc_in_place to trigger these alternatives only when needed.

Returns p if successful; otherwise null.

memalign

void * memalign(size_t , size_t )

Defined at malloc.c#5271

memalign(size_t alignment, size_t n); Returns a pointer to a newly allocated chunk of n bytes, aligned in accord with the alignment argument.

The alignment argument should be a power of two. If the argument is not a power of two, the nearest greater power is used. 8-byte alignment is guaranteed by normal malloc calls, so don't bother calling memalign with an argument of 8 or less.

Overreliance on memalign is a sure way to fragment space.

posix_memalign

int posix_memalign(void ** , size_t , size_t )

Defined at malloc.c#5278

int posix_memalign(void* pp, size_t alignment, size_t n); Allocates a chunk of n bytes, aligned in accord with the alignment argument. Differs from memalign only in that it (1) assigns the allocated memory to pp rather than returning it, (2) fails and returns EINVAL if the alignment is not a power of two (3) fails and returns ENOMEM if memory cannot be allocated.

valloc

void * valloc(size_t )

Defined at malloc.c#5301

valloc(size_t n); Equivalent to memalign(pagesize, n), where pagesize is the page size of the system. If the pagesize is unknown, 4096 is used.

mallopt

int mallopt(int , int )

Defined at malloc.c#5390

mallopt(int parameter_number, int parameter_value) Sets tunable parameters The format is to provide a (parameter-number, parameter-value) pair. mallopt then sets the corresponding parameter to the argument value if it can (i.e., so long as the value is meaningful), and returns 1 if successful else 0. To workaround the fact that mallopt is specified to use int, not size_t parameters, the value -1 is specially treated as the maximum unsigned size_t value.

SVID/XPG/ANSI defines four standard param numbers for mallopt, normally defined in malloc.h. None of these are use in this malloc, so setting them has no effect. But this malloc also supports other options in mallopt. See below for details. Briefly, supported parameters are as follows (listed defaults are for "typical" configurations).

Symbol param # default allowed param values M_TRIM_THRESHOLD -1 210241024 any (-1 disables) M_GRANULARITY -2 page size any power of 2 >= page size M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support)

malloc_footprint

size_t malloc_footprint()

Defined at malloc.c#5354

malloc_footprint(); Returns the number of bytes obtained from the system. The total number of bytes allocated by malloc, realloc etc., is less than this value. Unlike mallinfo, this function returns only a precomputed result, so can be called frequently to monitor memory consumption. Even if locks are otherwise defined, this function does not use them, so results might not be up to date.

malloc_max_footprint

size_t malloc_max_footprint()

Defined at malloc.c#5358

malloc_max_footprint(); Returns the maximum number of bytes obtained from the system. This value will be greater than current footprint if deallocated space has been reclaimed by the system. The peak number of bytes allocated by malloc, realloc etc., is less than this value. Unlike mallinfo, this function returns only a precomputed result, so can be called frequently to monitor memory consumption. Even if locks are otherwise defined, this function does not use them, so results might not be up to date.

malloc_footprint_limit

size_t malloc_footprint_limit()

Defined at malloc.c#5362

malloc_footprint_limit(); Returns the number of bytes that the heap is allowed to obtain from the system, returning the last value returned by malloc_set_footprint_limit, or the maximum size_t value if never set. The returned value reflects a permission. There is no guarantee that this number of bytes can actually be obtained from the system.

malloc_set_footprint_limit

size_t malloc_set_footprint_limit(size_t bytes)

Defined at malloc.c#5367

malloc_set_footprint_limit(); Sets the maximum number of bytes to obtain from the system, causing failure returns from malloc and related functions upon attempts to exceed this value. The argument value may be subject to page rounding to an enforceable limit; this actual value is returned. Using an argument of the maximum possible size_t effectively disables checks. If the argument is less than or equal to the current malloc_footprint, then all future allocations that require additional system memory will fail. However, invocation cannot retroactively deallocate existing used memory.

mallinfo

struct mallinfo mallinfo()

Defined at malloc.c#5379

mallinfo() Returns (by copy) a struct containing various summary statistics:

arena: current total non-mmapped bytes allocated from system ordblks: the number of free chunks smblks: always zero. hblks: current number of mmapped regions hblkhd: total bytes held in mmapped regions usmblks: the maximum total allocated space. This will be greater than current total if trimming has occurred. fsmblks: always zero uordblks: current total allocated space (normal or mmapped) fordblks: total free space keepcost: the maximum number of bytes that could ideally be released back to system via malloc_trim. ("ideally" means that it ignores page restrictions etc.)

Because these fields are ints, but internal bookkeeping may be kept as longs, the reported values may wrap around zero and thus be inaccurate.

independent_calloc

void ** independent_calloc(size_t , size_t , void ** )

Defined at malloc.c#5315

independent_calloc(size_t n_elements, size_t element_size, void* chunks[]);

independent_calloc is similar to calloc, but instead of returning a single cleared space, it returns an array of pointers to n_elements independent elements that can hold contents of size elem_size, each of which starts out cleared, and can be independently freed, realloc'ed etc. The elements are guaranteed to be adjacently allocated (this is not guaranteed to occur with multiple callocs or mallocs), which may also improve cache locality in some applications.

The "chunks" argument is optional (i.e., may be null, which is probably the most typical usage). If it is null, the returned array is itself dynamically allocated and should also be freed when it is no longer needed. Otherwise, the chunks array must be of at least n_elements in length. It is filled in with the pointers to the chunks.

In either case, independent_calloc returns this pointer array, or null if the allocation failed. If n_elements is zero and "chunks" is null, it returns a chunk representing an array with zero elements (which should be freed if not wanted).

Each element must be freed when it is no longer needed. This can be done all at once using bulk_free.

independent_calloc simplifies and speeds up implementations of many kinds of pools. It may also be useful when constructing large data structures that initially have a fixed number of fixed-sized nodes, but the number is not known at compile time, and some of the nodes may later need to be freed. For example:

struct Node { int item; struct Node* next; };

struct Node build_list() { struct Node pool; int n = read_number_of_nodes_needed(); if (n <= 0) return 0; pool = (struct Node)(independent_calloc(n, sizeof(struct Node), 0); if (pool == 0) die(); // organize into a linked list... struct Node first = pool[0]; for (i = 0; i < n-1; ++i) pool[i]->next = pool[i+1]; free(pool); // Can now free the array (or not, if it is needed later) return first; }

independent_comalloc

void ** independent_comalloc(size_t , size_t * , void ** )

Defined at malloc.c#5321

independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);

independent_comalloc allocates, all at once, a set of n_elements chunks with sizes indicated in the "sizes" array. It returns an array of pointers to these elements, each of which can be independently freed, realloc'ed etc. The elements are guaranteed to be adjacently allocated (this is not guaranteed to occur with multiple callocs or mallocs), which may also improve cache locality in some applications.

The "chunks" argument is optional (i.e., may be null). If it is null the returned array is itself dynamically allocated and should also be freed when it is no longer needed. Otherwise, the chunks array must be of at least n_elements in length. It is filled in with the pointers to the chunks.

In either case, independent_comalloc returns this pointer array, or null if the allocation failed. If n_elements is zero and chunks is null, it returns a chunk representing an array with zero elements (which should be freed if not wanted).

Each element must be freed when it is no longer needed. This can be done all at once using bulk_free.

independent_comallac differs from independent_calloc in that each element may have a different size, and also that it does not automatically clear elements.

independent_comalloc can be used to speed up allocation in cases where several structs or objects must always be allocated at the same time. For example:

struct Head { ... } struct Foot { ... }

void send_message(char msg) { int msglen = strlen(msg); size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; void chunks[3]; if (independent_comalloc(3, sizes, chunks) == 0) die(); struct Head head = (struct Head)(chunks[0]); char body = (char)(chunks[1]); struct Foot foot = (struct Foot)(chunks[2]); // ... }

In general though, independent_comalloc is worth using only for larger values of n_elements. For small values, you probably won't detect enough difference from series of malloc calls to bother.

Overuse of independent_comalloc can increase overall memory usage, since it cannot reuse existing noncontiguous small chunks that might be available for some of the elements.

bulk_free

size_t bulk_free(void ** , size_t n_elements)

Defined at malloc.c#5326

bulk_free(void* array[], size_t n_elements) Frees and clears (sets to null) each non-null pointer in the given array. This is likely to be faster than freeing them one-by-one. If footers are used, pointers that have been allocated in different mspaces are not freed or cleared, and the count of all such pointers is returned. For large arrays of pointers with poor locality, it may be worthwhile to sort this array before calling bulk_free.

pvalloc

void * pvalloc(size_t )

Defined at malloc.c#5308

pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize.

malloc_trim

int malloc_trim(size_t )

Defined at malloc.c#5344

malloc_trim(size_t pad);

If possible, gives memory back to the system (via negative arguments to sbrk) if there is unused memory at the `high' end of the malloc pool or in unused MMAP segments. You can call this after freeing large blocks of memory to potentially reduce the system-level memory requirements of a program. However, it cannot guarantee to reduce memory. Under some allocation patterns, some large free blocks of memory will be locked between two used chunks, so they cannot be given back to the system.

The `pad' argument to malloc_trim represents the amount of free trailing space to leave untrimmed. If this argument is zero, only the minimum amount of memory to maintain internal data structures will be left. Non-zero arguments can be supplied to maintain enough trailing space to service future expected allocations without having to re-obtain memory from the system.

Malloc_trim returns 1 if it actually released any memory, else 0.

malloc_usable_size

size_t malloc_usable_size(void * )

Defined at malloc.c#5394

malloc_usable_size(void* p);

Returns the number of bytes you can actually use in an allocated chunk, which may be more than you requested (although often not) due to alignment and minimum size constraints. You can use this many bytes without worrying about overwriting other allocated objects. This is not a particularly great programming practice. malloc_usable_size can be more useful in debugging and assertions, for example:

p = malloc(n); assert(malloc_usable_size(p) >= 256);

sbrk

void * sbrk(ptrdiff_t )

Enums

| enum |

--

| FAT_ERR_NONE | | FAT_ERR_NOFAT | | FAT_ERR_BROKEN | | FAT_ERR_IO | | FAT_ERR_PARAM | | FAT_ERR_PATH | | FAT_ERR_EOF | | FAT_ERR_DENIED | | FAT_ERR_FULL |

Defined at fat.h#15


| enum |

--

| FAT_ATTR_NONE | | FAT_ATTR_RO | | FAT_ATTR_HIDDEN | | FAT_ATTR_SYS | | FAT_ATTR_LABEL | | FAT_ATTR_DIR | | FAT_ATTR_ARCHIVE | | FAT_ATTR_LFN |

Defined at fat.h#27

| enum |

--

| FAT_BUF_DIRTY | | FAT_INFO_DIRTY |

Defined at fat.c#33


| enum |

--

| CLUST_FREE | | CLUST_USED | | CLUST_LAST | | CLUST_BAD |

Defined at fat.c#38

| enum |

--

| FAT_WRITE | | FAT_READ | | FAT_APPEND | | FAT_TRUNC | | FAT_CREATE | | FAT_ACCESSED | | FAT_MODIFIED | | FAT_FILE_DIRTY |

Defined at fat.h#38

| enum |

--

| FAT_SEEK_START | | FAT_SEEK_CURR | | FAT_SEEK_END |

Defined at fat.h#50

| enum |

--

| noDictCtx | | usingDictCtxHc |

Defined at lz4hc.c#68

=== Enums ===

| enum |

--

| XXH_OK | | XXH_ERROR |

Defined at ./xxhash.h#78

| enum |

--

| lz4mid | | lz4hc | | lz4opt |

Defined at lz4hc.c#79

=== Levels definition ===

| enum |

--

| LZ4F_default | | LZ4F_max64KB | | LZ4F_max256KB | | LZ4F_max1MB | | LZ4F_max4MB |

Defined at ./lz4frame.h#123

The larger the block size, the (slightly) better the compression ratio, though there are diminishing returns. Larger blocks also increase memory usage on both compression and decompression sides.

| enum |

--

| LZ4F_blockLinked | | LZ4F_blockIndependent |

Defined at ./lz4frame.h#135

Linked blocks sharply reduce inefficiencies when using small blocks, they compress better. However, some LZ4 decoders are only compatible with independent blocks

| enum |

--

| LZ4F_noContentChecksum | | LZ4F_contentChecksumEnabled |

Defined at ./lz4frame.h#140

| enum |

--

| LZ4F_noBlockChecksum | | LZ4F_blockChecksumEnabled |

Defined at ./lz4frame.h#146

| enum |

--

| LZ4F_frame | | LZ4F_skippableFrame |

Defined at ./lz4frame.h#148

| enum |

--

| XXH_bigEndian | | XXH_littleEndian |

Defined at xxhash.c#234

***** Architecture Macros*****

| enum |

--

| XXH_aligned | | XXH_unaligned |

Defined at xxhash.c#252

***** Memory reads*******

| enum |

--

| LZ4B_COMPRESSED | | LZ4B_UNCOMPRESSED |

Defined at lz4frame.c#268

-***** Structures and local types*****

| enum |

--

| ctxNone | | ctxFast | | ctxHC |

Defined at lz4frame.c#269

| enum |

--

| notLimited | | limitedOutput | | fillOutput |

Defined at lz4.c#343

| enum |

--

| LZ4F_OK_NoError | | LZ4F_ERROR_GENERIC | | LZ4F_ERROR_maxBlockSize_invalid | | LZ4F_ERROR_blockMode_invalid | | LZ4F_ERROR_parameter_invalid | | LZ4F_ERROR_compressionLevel_invalid | | LZ4F_ERROR_headerVersion_wrong | | LZ4F_ERROR_blockChecksum_invalid | | LZ4F_ERROR_reservedFlag_set | | LZ4F_ERROR_allocation_failed | | LZ4F_ERROR_srcSize_tooLarge | | LZ4F_ERROR_dstMaxSize_tooSmall | | LZ4F_ERROR_frameHeader_incomplete | | LZ4F_ERROR_frameType_unknown | | LZ4F_ERROR_frameSize_wrong | | LZ4F_ERROR_srcPtr_wrong | | LZ4F_ERROR_decompressionFailed | | LZ4F_ERROR_headerChecksum_invalid | | LZ4F_ERROR_contentChecksum_invalid | | LZ4F_ERROR_frameDecoding_alreadyStarted | | LZ4F_ERROR_compressionState_uninitialized | | LZ4F_ERROR_parameter_null | | LZ4F_ERROR_io_write | | LZ4F_ERROR_io_read | | LZ4F_ERROR_maxCode | | _LZ4F_dummy_error_enum_for_c89_never_used |

Defined at ./lz4frame.h#702

enum list is exposed, to handle specific errors

| enum |

--

| clearedTable | | byPtr | | byU32 | | byU16 |

Defined at lz4.c#787

-***** Local Structures and types*****

| enum |

--

| noDict | | withPrefix64k | | usingExtDict | | usingDictCtx |

Defined at lz4.c#812

This enum distinguishes several different modes of accessing previous content in the stream.

  • noDict : There is no preceding content. - withPrefix64k : Table entries up to ctx->dictSize before the current blob blob being compressed are valid and refer to the preceding content (of length ctx->dictSize), which is available contiguously preceding in memory the content currently being compressed. - usingExtDict : Like withPrefix64k, but the preceding content is somewhere else in memory, starting at ctx->dictionary with length ctx->dictSize. - usingDictCtx : Everything concerning the preceding content is in a separate context, pointed to by ctx->dictCtx. ctx->dictionary, ctx->dictSize, and table entries in the current context that refer to positions preceding the beginning of the current compression are ignored. Instead, ctx->dictCtx->dictionary and ctx->dictCtx ->dictSize describe the location and size of the preceding content, and matches are found by looking in the ctx ->dictCtx->hashTable.

| enum |

--

| noDictIssue | | dictSmall |

Defined at lz4.c#813

| enum |

--

| rep_untested | | rep_not | | rep_confirmed |

Defined at lz4hc.c#952

| enum |

--

| favorCompressionRatio | | favorDecompressionSpeed |

Defined at lz4hc.c#953

| enum |

--

| notDone | | fromTmpBuffer | | fromSrcBuffer |

Defined at lz4frame.c#1029

| enum |

--

| dstage_getFrameHeader | | dstage_storeFrameHeader | | dstage_init | | dstage_getBlockHeader | | dstage_storeBlockHeader | | dstage_copyDirect | | dstage_getBlockChecksum | | dstage_getCBlock | | dstage_storeCBlock | | dstage_flushOut | | dstage_getSuffix | | dstage_storeSuffix | | dstage_getSFrameSize | | dstage_storeSFrameSize | | dstage_skipSkippable |

Defined at lz4frame.c#1295

-******* Frame Decompression*******

| enum |

--

| _ld_fast | | _ld_slow |

Defined at lz4.c#1777

| enum |

--

| decode_full_block | | partial_decode |

Defined at lz4.c#2064

-**** Decompression functions*****