~donmcc/astr

ref: f3b4c1fa29f1aeedce1aabf6b2f8a55673797313 astr/astr.h -rw-r--r-- 665 bytes
f3b4c1faDon McCaughey Change _args suffix to _with_va_list. 1 year, 10 months ago
                                                                                
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
#ifndef ASTR_H_INCLUDED
#define ASTR_H_INCLUDED


#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>


char *
astr_alloc_formatted(char const *format, ...);

char *
astr_alloc_formatted_from_va_list(char const *format, va_list arguments);

size_t
astr_formatted_length(char const *format, ...);

size_t
astr_formatted_length_from_va_list(char const *format, va_list arguments);


inline char *
astr_alloc_empty(void)
{
    return calloc(1, sizeof(char));
}

inline bool
astr_eq(char const *s1, char const *s2)
{
    if (s1 == s2) return true;
    if (NULL == s1 || NULL == s2) return false;
    return 0 == strcmp(s1, s2);
}


#endif