PX4 Firmware
PX4 Autopilot Software http://px4.io
utstring.h File Reference
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
Include dependency graph for utstring.h:

Go to the source code of this file.

Classes

struct  UT_string
 

Macros

#define UTSTRING_VERSION   1.9.6
 
#define _UNUSED_
 
#define oom()   exit(-1)
 
#define utstring_reserve(s, amt)
 
#define utstring_init(s)
 
#define utstring_done(s)
 
#define utstring_free(s)
 
#define utstring_new(s)
 
#define utstring_renew(s)
 
#define utstring_clear(s)
 
#define utstring_bincpy(s, b, l)
 
#define utstring_concat(dst, src)
 
#define utstring_len(s)   ((unsigned)((s)->i))
 
#define utstring_body(s)   ((s)->d)
 

Functions

static _UNUSED_ void utstring_printf_va (UT_string *s, const char *fmt, va_list ap)
 
static _UNUSED_ void utstring_printf (UT_string *s, const char *fmt,...)
 

Macro Definition Documentation

◆ _UNUSED_

#define _UNUSED_

Definition at line 35 of file utstring.h.

◆ oom

#define oom ( )    exit(-1)

Definition at line 41 of file utstring.h.

◆ utstring_bincpy

#define utstring_bincpy (   s,
  b,
 
)
Value:
do { \
utstring_reserve((s),(l)+1); \
if (l) memcpy(&(s)->d[(s)->i], b, l); \
(s)->i += l; \
(s)->d[(s)->i]='\0'; \
} while(0)

Definition at line 99 of file utstring.h.

◆ utstring_body

#define utstring_body (   s)    ((s)->d)

Definition at line 117 of file utstring.h.

◆ utstring_clear

#define utstring_clear (   s)
Value:
do { \
(s)->i = 0; \
(s)->d[0] = '\0'; \
} while(0)

Definition at line 93 of file utstring.h.

◆ utstring_concat

#define utstring_concat (   dst,
  src 
)
Value:
do { \
utstring_reserve((dst),((src)->i)+1); \
if ((src)->i) memcpy(&(dst)->d[(dst)->i], (src)->d, (src)->i); \
(dst)->i += (src)->i; \
(dst)->d[(dst)->i]='\0'; \
} while(0)

Definition at line 107 of file utstring.h.

◆ utstring_done

#define utstring_done (   s)
Value:
do { \
if ((s)->d != NULL) free((s)->d); \
(s)->n = 0; \
} while(0)

Definition at line 65 of file utstring.h.

◆ utstring_free

#define utstring_free (   s)
Value:
do { \
utstring_done(s); \
free(s); \
} while(0)

Definition at line 71 of file utstring.h.

◆ utstring_init

#define utstring_init (   s)
Value:
do { \
(s)->n = 0; (s)->i = 0; (s)->d = NULL; \
utstring_reserve(s,100); \
(s)->d[0] = '\0'; \
} while(0)

Definition at line 58 of file utstring.h.

◆ utstring_len

#define utstring_len (   s)    ((unsigned)((s)->i))

Definition at line 115 of file utstring.h.

◆ utstring_new

#define utstring_new (   s)
Value:
do { \
s = (UT_string*)calloc(sizeof(UT_string),1); \
if (!s) oom(); \
utstring_init(s); \
} while(0)
#define oom()
Definition: utstring.h:41

Definition at line 77 of file utstring.h.

◆ utstring_renew

#define utstring_renew (   s)
Value:
do { \
if (s) { \
utstring_clear(s); \
} else { \
utstring_new(s); \
} \
} while(0)

Definition at line 84 of file utstring.h.

◆ utstring_reserve

#define utstring_reserve (   s,
  amt 
)
Value:
do { \
if (((s)->n - (s)->i) < (size_t)(amt)) { \
(s)->d = (char*)realloc((s)->d, (s)->n + amt); \
if ((s)->d == NULL) oom(); \
(s)->n += amt; \
} \
} while(0)
#define oom()
Definition: utstring.h:41

Definition at line 49 of file utstring.h.

Referenced by utstring_printf_va().

◆ UTSTRING_VERSION

#define UTSTRING_VERSION   1.9.6

Definition at line 30 of file utstring.h.

Function Documentation

◆ utstring_printf()

static _UNUSED_ void utstring_printf ( UT_string s,
const char *  fmt,
  ... 
)
static

Definition at line 141 of file utstring.h.

References utstring_printf_va().

Here is the call graph for this function:

◆ utstring_printf_va()

static _UNUSED_ void utstring_printf_va ( UT_string s,
const char *  fmt,
va_list  ap 
)
static

Definition at line 119 of file utstring.h.

References UT_string::d, UT_string::i, UT_string::n, and utstring_reserve.

Referenced by utstring_printf().

Here is the caller graph for this function: