~donmcc/astr

ref: 8f2fd999ba6bf5d5dd8abc905cc12cf5838d2409 astr/astr.h -rw-r--r-- 614 bytes
8f2fd999Don McCaughey Replace ternary expression with if statement. 2 years 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
#ifndef ASTR_H_INCLUDED
#define ASTR_H_INCLUDED


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


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

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

inline char *
astr_alloc_empty(void)
{
    return astr_alloc_format("");
}

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

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

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


#endif