~donmcc/astr

ref: 6a7af5061199752b6dc6c374b8162d4eec212169 astr/astr.h -rw-r--r-- 649 bytes
6a7af506Don McCaughey Renamed functions with "_format" in their names. 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_args(char const *format, va_list arguments);

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

size_t
astr_formatted_length_args(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