~donmcc/astr

ref: 6a7af5061199752b6dc6c374b8162d4eec212169 astr/README.md -rw-r--r-- 2.1 KiB
6a7af506Don McCaughey Renamed functions with "_format" in their names. 1 year, 10 months ago

#astr

A C99 library for working with dynamically allocated strings.

builds.sr.ht status

#Overview

All functions in astr begin with the astr_ prefix. Functions that return newly allocated strings will contain _alloc in their names; the caller is responsible for calling free() on the returned pointer. Functions with _format take a printf() style format string. Functions that end with the suffix _args take variable arguments as a va_list object from stdarg.h.

#Functions

char *
astr_alloc_empty(void);

Allocate an empty string.

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

Allocate a formatted string.

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

Allocate a formatted string using a va_list object.

bool
astr_eq(char const *s1, char const *s2);

Compare the bytes of two strings for equality; s1 and s2 may be NULL.

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

Calculate the length in bytes needed for the formatted string.

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

Calculate the length in bytes needed for the formatted string using a va_list object.

#Dependencies

astr requires that <stdio.h> defines the vasprintf() and vsnprintf() functions. Building from repository source requires GNU Autotools.

#Building from Repository Source

Clone the repository then generate the configure script, configure and build.

git clone https://git.sr.ht/~donmcc/astr
cd astr
autoreconf -i
mkdir tmp && cd tmp
../configure && make && sudo make install

#License

astr is made available under a BSD-style license; see the LICENSE file for details.