Project Alice
Loading...
Searching...
No Matches
hist.c File Reference
#include "../common/mem.h"
#include "../common/debug.h"
#include "../common/error_private.h"
#include "hist.h"
Include dependency graph for hist.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  HIST_checkInput_e { trustInput , checkMaxSymbolValue }
 

Functions

unsigned HIST_isError (size_t code)
 
unsigned HIST_count_simple (unsigned *count, unsigned *maxSymbolValuePtr, const void *src, size_t srcSize)
 
size_t HIST_countFast_wksp (unsigned *count, unsigned *maxSymbolValuePtr, const void *source, size_t sourceSize, void *workSpace, size_t workSpaceSize)
 
size_t HIST_count_wksp (unsigned *count, unsigned *maxSymbolValuePtr, const void *source, size_t sourceSize, void *workSpace, size_t workSpaceSize)
 
size_t HIST_countFast (unsigned *count, unsigned *maxSymbolValuePtr, const void *source, size_t sourceSize)
 
size_t HIST_count (unsigned *count, unsigned *maxSymbolValuePtr, const void *src, size_t srcSize)
 

Enumeration Type Documentation

◆ HIST_checkInput_e

Enumerator
trustInput 
checkMaxSymbolValue 

Definition at line 56 of file hist.c.

Function Documentation

◆ HIST_count()

size_t HIST_count ( unsigned *  count,
unsigned *  maxSymbolValuePtr,
const void *  src,
size_t  srcSize 
)

HIST_count(): Provides the precise count of each byte within a table 'count'. 'count' is a table of unsigned int, of minimum size (*maxSymbolValuePtr+1). Updates *maxSymbolValuePtr with actual largest symbol value detected.

Returns
: count of the most frequent symbol (which isn't identified). or an error code, which can be tested using HIST_isError(). note : if return == srcSize, there is only one symbol.

Definition at line 175 of file hist.c.

Here is the call graph for this function:

◆ HIST_count_simple()

unsigned HIST_count_simple ( unsigned *  count,
unsigned *  maxSymbolValuePtr,
const void *  src,
size_t  srcSize 
)

HIST_count_simple() : Same as HIST_countFast(), this function is unsafe, and will segfault if any value within src is > *maxSymbolValuePtr. It is also a bit slower for large inputs. However, it does not need any additional memory (not even on stack).

Returns
: count of the most frequent symbol. Note this function doesn't produce any error (i.e. it must succeed).

Definition at line 29 of file hist.c.

Here is the caller graph for this function:

◆ HIST_count_wksp()

size_t HIST_count_wksp ( unsigned *  count,
unsigned *  maxSymbolValuePtr,
const void *  src,
size_t  srcSize,
void *  workSpace,
size_t  workSpaceSize 
)

HIST_count_wksp() : Same as HIST_count(), but using an externally provided scratch buffer. Benefit is this function will use very little stack space. workSpace is a writable buffer which must be 4-bytes aligned, workSpaceSize must be >= HIST_WKSP_SIZE

Definition at line 154 of file hist.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HIST_countFast()

size_t HIST_countFast ( unsigned *  count,
unsigned *  maxSymbolValuePtr,
const void *  src,
size_t  srcSize 
)

HIST_countFast() : same as HIST_count(), but blindly trusts that all byte values within src are <= *maxSymbolValuePtr. This function is unsafe, and will segfault if any value within src is > *maxSymbolValuePtr

Definition at line 168 of file hist.c.

Here is the call graph for this function:

◆ HIST_countFast_wksp()

size_t HIST_countFast_wksp ( unsigned *  count,
unsigned *  maxSymbolValuePtr,
const void *  src,
size_t  srcSize,
void *  workSpace,
size_t  workSpaceSize 
)

HIST_countFast_wksp() : Same as HIST_countFast(), but using an externally provided scratch buffer. workSpace is a writable buffer which must be 4-bytes aligned, workSpaceSize must be >= HIST_WKSP_SIZE

Definition at line 140 of file hist.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HIST_isError()

unsigned HIST_isError ( size_t  code)

tells if a return value is an error code

Definition at line 24 of file hist.c.

Here is the call graph for this function: