5 // Miscellaneous utilities
6 // -----------------------
12 // return the value coresponding to an hexadecimal digit
13 unsigned int hexval(unsigned int c
);
16 // duplicate a memory buffer in a newly allocated buffer.
17 // @src: a pointer to the memory buffer to be duplicated
18 // @len: the size of the memory buffer to be duplicated
19 // @return: a pointer to a copy of @src allocated via
20 // :func:`__alloc_bytes()`.
21 void *xmemdup(const void *src
, size_t len
);
24 // duplicate a null-terminated string in a newly allocated buffer.
25 // @src: a pointer to string to be duplicated
26 // @return: a pointer to a copy of @str allocated via
27 // :func:`__alloc_bytes()`.
28 char *xstrdup(const char *src
);
31 // printf to allocated string
32 // @fmt: the format followed by its arguments.
33 // @return: the allocated & formatted string.
34 // This function is similar to asprintf() but the resulting string
35 // is allocated with __alloc_bytes().
36 char *xasprintf(const char *fmt
, ...);
39 // vprintf to allocated string
41 // @ap: the variadic arguments
42 // @return: the allocated & formatted string.
43 // This function is similar to asprintf() but the resulting string
44 // is allocated with __alloc_bytes().
45 char *xvasprintf(const char *fmt
, va_list ap
);