libgpac
Documentation of the core library of GPAC
cutils.h File Reference
#include <stdlib.h>
#include <inttypes.h>
+ Include dependency graph for cutils.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  DynBuf
 

Macros

#define likely(x)   __builtin_expect(!!(x), 1)
 
#define unlikely(x)   __builtin_expect(!!(x), 0)
 
#define force_inline   inline __attribute__((always_inline))
 
#define no_inline   __attribute__((noinline))
 
#define __maybe_unused   __attribute__((unused))
 
#define xglue(x, y)   x ## y
 
#define glue(x, y)   xglue(x, y)
 
#define stringify(s)   tostring(s)
 
#define tostring(s)   #s
 
#define offsetof(type, field)   ((size_t) &((type *)0)->field)
 
#define countof(x)   (sizeof(x) / sizeof((x)[0]))
 
#define UTF8_CHAR_LEN_MAX   6
 

Typedefs

typedef int BOOL
 
typedef void * DynBufReallocFunc(void *opaque, void *ptr, size_t size)
 

Enumerations

enum  { FALSE = 0 , TRUE = 1 }
 

Functions

void pstrcpy (char *buf, int buf_size, const char *str)
 
char * pstrcat (char *buf, int buf_size, const char *s)
 
int strstart (const char *str, const char *val, const char **ptr)
 
int has_suffix (const char *str, const char *suffix)
 
static int max_int (int a, int b)
 
static int min_int (int a, int b)
 
static uint32_t max_uint32 (uint32_t a, uint32_t b)
 
static uint32_t min_uint32 (uint32_t a, uint32_t b)
 
static int64_t max_int64 (int64_t a, int64_t b)
 
static int64_t min_int64 (int64_t a, int64_t b)
 
static int clz32 (unsigned int a)
 
static int clz64 (uint64_t a)
 
static int ctz32 (unsigned int a)
 
static int ctz64 (uint64_t a)
 
struct __attribute__ ((packed)) packed_u64
 
static uint64_t get_u64 (const uint8_t *tab)
 
static int64_t get_i64 (const uint8_t *tab)
 
static void put_u64 (uint8_t *tab, uint64_t val)
 
static uint32_t get_u32 (const uint8_t *tab)
 
static int32_t get_i32 (const uint8_t *tab)
 
static void put_u32 (uint8_t *tab, uint32_t val)
 
static uint32_t get_u16 (const uint8_t *tab)
 
static int32_t get_i16 (const uint8_t *tab)
 
static void put_u16 (uint8_t *tab, uint16_t val)
 
static uint32_t get_u8 (const uint8_t *tab)
 
static int32_t get_i8 (const uint8_t *tab)
 
static void put_u8 (uint8_t *tab, uint8_t val)
 
static uint16_t bswap16 (uint16_t x)
 
static uint32_t bswap32 (uint32_t v)
 
static uint64_t bswap64 (uint64_t v)
 
void dbuf_init (DynBuf *s)
 
void dbuf_init2 (DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func)
 
int dbuf_realloc (DynBuf *s, size_t new_size)
 
int dbuf_write (DynBuf *s, size_t offset, const uint8_t *data, size_t len)
 
int dbuf_put (DynBuf *s, const uint8_t *data, size_t len)
 
int dbuf_put_self (DynBuf *s, size_t offset, size_t len)
 
int dbuf_putc (DynBuf *s, uint8_t c)
 
int dbuf_putstr (DynBuf *s, const char *str)
 
static int dbuf_put_u16 (DynBuf *s, uint16_t val)
 
static int dbuf_put_u32 (DynBuf *s, uint32_t val)
 
static int dbuf_put_u64 (DynBuf *s, uint64_t val)
 
int __attribute__ ((format(printf, 2, 3))) dbuf_printf(DynBuf *s
 
int const char void dbuf_free (DynBuf *s)
 
static BOOL dbuf_error (DynBuf *s)
 
static void dbuf_set_error (DynBuf *s)
 
int unicode_to_utf8 (uint8_t *buf, unsigned int c)
 
int unicode_from_utf8 (const uint8_t *p, int max_len, const uint8_t **pp)
 
static int from_hex (int c)
 
void rqsort (void *base, size_t nmemb, size_t size, int(*cmp)(const void *, const void *, void *), void *arg)
 

Variables

int const char * fmt
 

Data Structure Documentation

◆ DynBuf

struct DynBuf
Data Fields
uint8_t * buf
size_t size
size_t allocated_size
BOOL error
DynBufReallocFunc * realloc_func
void * opaque

Macro Definition Documentation

◆ likely

#define likely (   x)    __builtin_expect(!!(x), 1)

◆ unlikely

#define unlikely (   x)    __builtin_expect(!!(x), 0)

◆ force_inline

#define force_inline   inline __attribute__((always_inline))

◆ no_inline

#define no_inline   __attribute__((noinline))

◆ __maybe_unused

#define __maybe_unused   __attribute__((unused))

◆ xglue

#define xglue (   x,
 
)    x ## y

◆ glue

#define glue (   x,
 
)    xglue(x, y)

◆ stringify

#define stringify (   s)    tostring(s)

◆ tostring

#define tostring (   s)    #s

◆ offsetof

#define offsetof (   type,
  field 
)    ((size_t) &((type *)0)->field)

◆ countof

#define countof (   x)    (sizeof(x) / sizeof((x)[0]))

◆ UTF8_CHAR_LEN_MAX

#define UTF8_CHAR_LEN_MAX   6

Typedef Documentation

◆ BOOL

typedef int BOOL

◆ DynBufReallocFunc

typedef void* DynBufReallocFunc(void *opaque, void *ptr, size_t size)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FALSE 
TRUE 

Function Documentation

◆ pstrcpy()

void pstrcpy ( char *  buf,
int  buf_size,
const char *  str 
)
+ Here is the caller graph for this function:

◆ pstrcat()

char* pstrcat ( char *  buf,
int  buf_size,
const char *  s 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ strstart()

int strstart ( const char *  str,
const char *  val,
const char **  ptr 
)
+ Here is the caller graph for this function:

◆ has_suffix()

int has_suffix ( const char *  str,
const char *  suffix 
)
+ Here is the caller graph for this function:

◆ max_int()

static int max_int ( int  a,
int  b 
)
static
+ Here is the caller graph for this function:

◆ min_int()

static int min_int ( int  a,
int  b 
)
static
+ Here is the caller graph for this function:

◆ max_uint32()

static uint32_t max_uint32 ( uint32_t  a,
uint32_t  b 
)
static
+ Here is the caller graph for this function:

◆ min_uint32()

static uint32_t min_uint32 ( uint32_t  a,
uint32_t  b 
)
static
+ Here is the caller graph for this function:

◆ max_int64()

static int64_t max_int64 ( int64_t  a,
int64_t  b 
)
static
+ Here is the caller graph for this function:

◆ min_int64()

static int64_t min_int64 ( int64_t  a,
int64_t  b 
)
static
+ Here is the caller graph for this function:

◆ clz32()

static int clz32 ( unsigned int  a)
static
+ Here is the caller graph for this function:

◆ clz64()

static int clz64 ( uint64_t  a)
static
+ Here is the caller graph for this function:

◆ ctz32()

static int ctz32 ( unsigned int  a)
static
+ Here is the caller graph for this function:

◆ ctz64()

static int ctz64 ( uint64_t  a)
static
+ Here is the caller graph for this function:

◆ __attribute__() [1/2]

struct __attribute__ ( (packed)  )

◆ get_u64()

static uint64_t get_u64 ( const uint8_t tab)
static
+ Here is the caller graph for this function:

◆ get_i64()

static int64_t get_i64 ( const uint8_t tab)
static

◆ put_u64()

static void put_u64 ( uint8_t tab,
uint64_t  val 
)
static
+ Here is the caller graph for this function:

◆ get_u32()

static uint32_t get_u32 ( const uint8_t tab)
static

◆ get_i32()

static int32_t get_i32 ( const uint8_t tab)
static
+ Here is the caller graph for this function:

◆ put_u32()

static void put_u32 ( uint8_t tab,
uint32_t  val 
)
static
+ Here is the caller graph for this function:

◆ get_u16()

static uint32_t get_u16 ( const uint8_t tab)
static
+ Here is the caller graph for this function:

◆ get_i16()

static int32_t get_i16 ( const uint8_t tab)
static
+ Here is the caller graph for this function:

◆ put_u16()

static void put_u16 ( uint8_t tab,
uint16_t  val 
)
static
+ Here is the caller graph for this function:

◆ get_u8()

static uint32_t get_u8 ( const uint8_t tab)
static
+ Here is the caller graph for this function:

◆ get_i8()

static int32_t get_i8 ( const uint8_t tab)
static
+ Here is the caller graph for this function:

◆ put_u8()

static void put_u8 ( uint8_t tab,
uint8_t  val 
)
static
+ Here is the caller graph for this function:

◆ bswap16()

static uint16_t bswap16 ( uint16_t  x)
static
+ Here is the caller graph for this function:

◆ bswap32()

static uint32_t bswap32 ( uint32_t  v)
static
+ Here is the caller graph for this function:

◆ bswap64()

static uint64_t bswap64 ( uint64_t  v)
static
+ Here is the caller graph for this function:

◆ dbuf_init()

void dbuf_init ( DynBuf s)
+ Here is the call graph for this function:

◆ dbuf_init2()

void dbuf_init2 ( DynBuf s,
void *  opaque,
DynBufReallocFunc realloc_func 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbuf_realloc()

int dbuf_realloc ( DynBuf s,
size_t  new_size 
)
+ Here is the caller graph for this function:

◆ dbuf_write()

int dbuf_write ( DynBuf s,
size_t  offset,
const uint8_t data,
size_t  len 
)
+ Here is the call graph for this function:

◆ dbuf_put()

int dbuf_put ( DynBuf s,
const uint8_t data,
size_t  len 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbuf_put_self()

int dbuf_put_self ( DynBuf s,
size_t  offset,
size_t  len 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbuf_putc()

int dbuf_putc ( DynBuf s,
uint8_t  c 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbuf_putstr()

int dbuf_putstr ( DynBuf s,
const char *  str 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbuf_put_u16()

static int dbuf_put_u16 ( DynBuf s,
uint16_t  val 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbuf_put_u32()

static int dbuf_put_u32 ( DynBuf s,
uint32_t  val 
)
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbuf_put_u64()

static int dbuf_put_u64 ( DynBuf s,
uint64_t  val 
)
static
+ Here is the call graph for this function:

◆ __attribute__() [2/2]

int __attribute__ ( (format(printf, 2, 3))  )

◆ dbuf_free()

int const char void dbuf_free ( DynBuf s)
+ Here is the caller graph for this function:

◆ dbuf_error()

static BOOL dbuf_error ( DynBuf s)
static
+ Here is the caller graph for this function:

◆ dbuf_set_error()

static void dbuf_set_error ( DynBuf s)
static
+ Here is the caller graph for this function:

◆ unicode_to_utf8()

int unicode_to_utf8 ( uint8_t buf,
unsigned int  c 
)
+ Here is the caller graph for this function:

◆ unicode_from_utf8()

int unicode_from_utf8 ( const uint8_t p,
int  max_len,
const uint8_t **  pp 
)
+ Here is the caller graph for this function:

◆ from_hex()

static int from_hex ( int  c)
static
+ Here is the caller graph for this function:

◆ rqsort()

void rqsort ( void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *, void *)  cmp,
void *  arg 
)

Variable Documentation

◆ fmt

JSValue const char JSValue const char JSValue const char JSValue const char JSValue const char * fmt