equal
deleted
inserted
replaced
1 #ifndef FLIB_UTIL_H_ |
|
2 #define FLIB_UTIL_H_ |
|
3 |
|
4 #include <stddef.h> |
|
5 #include <stdarg.h> |
|
6 |
|
7 /** |
|
8 * Prints a format string to a newly allocated buffer of the required size. |
|
9 * Parameters are like those for printf. Returns NULL on error. |
|
10 * |
|
11 * Returned buffer must be free()d |
|
12 */ |
|
13 char *flib_asprintf(const char *fmt, ...); |
|
14 |
|
15 /** |
|
16 * Exactly as flib_asprintf, but accepts va_args. |
|
17 */ |
|
18 char *flib_vasprintf(const char *fmt, va_list args); |
|
19 |
|
20 /** |
|
21 * Return a duplicate of the provided string, or NULL if an error |
|
22 * occurs or if str is already NULL. |
|
23 * |
|
24 * Returned buffer must be free()d |
|
25 */ |
|
26 char *flib_strdupnull(const char *str); |
|
27 |
|
28 /** |
|
29 * Return a duplicate of the provided buffer, or NULL if an error |
|
30 * occurs or if buf is already NULL or if size is 0. |
|
31 * |
|
32 * Returned buffer must be free()d |
|
33 */ |
|
34 void *flib_bufdupnull(const void *buf, size_t size); |
|
35 |
|
36 #endif |
|