summaryrefslogtreecommitdiff
path: root/src/lib/store/store_utils.c
blob: 00b89d0ecff1fd38b411857ce3be9ac16775f645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#define _GNU_SOURCE
#include <stdio.h>

#include "store_private.h"


/**
 * @addtogroup Lib-Store-Functions
 * @{
 */

/**
 * @cond IGNORE
 */


/**
 * @brief Creates a new string from a format string.
 * @param s the NULL-terminated format string to retrieve an instance of.
 * @return A pointer to the allocated buffer. NULL on failure.
 */
char *
store_utils_dupf(const char *s, ...)
{
   va_list args;
   int len;
   char *str;

   va_start(args, s);
   len = vasprintf(&str, s, args);
   va_end(args);

   if (len == -1)
     return NULL;

   return str;
}

/**
 * @endcond
 */

/**
 * @}
 */