about summary refs log tree commit diff
path: root/stringutil.h
blob: c7cb40d9bdc42255e5461fba7afdf1031724b3f2 (plain) (blame)
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
/*!
 * @file
 * @brief Utilities for string construction
 */

/*!
 * @brief Returns hex digit for given integer
 *
 * Will return appropriate `char` in range 0-F
 * for input in range 0-15. Can be abused to
 * return decimal digits for range 0-9.
 */
char nibble_hex(short h);

/*!
 * @brief Concatenate arbitrary number of strings into
 * dynamically allocated buffer
 *
 * catn_alloc() concats the `n` given strings into a
 * dynamically allocated and resized buffer and returns
 * it. This buffer must be cleaned up by `free()` before
 * it goes out of scope.
 *
 * @param n number of strings given as `va_args`
 * @return pointer to concatenated strings or `NULL` on error.
 */
char *catn_alloc(size_t n, ...);