libxputty  0.1
A damn tiny abstraction Layer to create X11 window/widgets with cairo surfaces
xasprintf.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XASPRINTF_H_
 

Functions

int _vscprintf_so (const char *format, va_list pargs)
 
int vasprintf (char **strp, const char *fmt, va_list ap)
 
int asprintf (char *strp[], const char *fmt,...)
 

Macro Definition Documentation

◆ XASPRINTF_H_

#define XASPRINTF_H_

Definition at line 12 of file xasprintf.h.

Function Documentation

◆ _vscprintf_so()

int _vscprintf_so ( const char *  format,
va_list  pargs 
)

Definition at line 16 of file xasprintf.c.

16  {
17  int retval;
18  va_list argcopy;
19  va_copy(argcopy, pargs);
20  retval = vsnprintf(NULL, 0, format, argcopy);
21  va_end(argcopy);
22  return retval;
23 }

◆ asprintf()

int asprintf ( char *  strp[],
const char *  fmt,
  ... 
)

Definition at line 36 of file xasprintf.c.

36  {
37  va_list ap;
38  va_start(ap, fmt);
39  int r = vasprintf(strp, fmt, ap);
40  va_end(ap);
41  return r;
42 }

References vasprintf().

◆ vasprintf()

int vasprintf ( char **  strp,
const char *  fmt,
va_list  ap 
)

Definition at line 25 of file xasprintf.c.

25  {
26  int len = _vscprintf_so(fmt, ap);
27  if (len == -1) return -1;
28  char *str = malloc((size_t) len + 1);
29  if (!str) return -1;
30  int r = vsnprintf(str, len + 1, fmt, ap);
31  if (r == -1) return free(str), -1;
32  *strp = str;
33  return r;
34 }

References _vscprintf_so().

vasprintf
int vasprintf(char **strp, const char *fmt, va_list ap)
Definition: xasprintf.c:25
_vscprintf_so
int _vscprintf_so(const char *format, va_list pargs)
Definition: xasprintf.c:16