Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Implementation of temporary buffers with round-robin usage pattern.
Definition in file tmpbuf.c.
#include "lib/safeclib.h"
#include "lib/tmpbuf.h"
#include <string.h>
#include <pthread.h>
#include <stdint.h>
#include <stdarg.h>
#include <nobug.h>
Classes | |
struct | lumiera_tmpbuf_struct |
Functions | |
static void | lumiera_tmpbuf_destroy (void *buf) |
void | lumiera_tmpbuf_freeall (void) |
free all buffers associated with this thread. More... | |
static void | lumiera_tmpbuf_init (void) |
void * | lumiera_tmpbuf_provide (size_t size) |
Query a thread local tmpbuf. More... | |
char * | lumiera_tmpbuf_snprintf (size_t size, const char *fmt,...) |
Construct a string in a tmpbuf. More... | |
char * | lumiera_tmpbuf_strcat3 (const char *str1, size_t str1_len, const char *str2, size_t str2_len, const char *str3, size_t str3_len) |
Concat up to 3 strings in a tmpbuf. More... | |
char * | lumiera_tmpbuf_strndup (const char *src, size_t size) |
Duplicate string to a tmpbuf. More... | |
char * | lumiera_tmpbuf_tr (const char *in, const char *from, const char *to, const char *def) |
Translates characters in a string, similar to the shell 'tr' utility. More... | |
Variables | |
static pthread_key_t | lumiera_tmpbuf_tls_key |
static pthread_once_t | lumiera_tmpbuf_tls_once = PTHREAD_ONCE_INIT |
struct lumiera_tmpbuf_struct |
void lumiera_tmpbuf_freeall | ( | void | ) |
void* lumiera_tmpbuf_provide | ( | size_t | size | ) |
Query a thread local tmpbuf.
size | minimal needed size for the tmpbuf |
Definition at line 89 of file tmpbuf.c.
Referenced by lumiera_tmpbuf_strndup().
char* lumiera_tmpbuf_strndup | ( | const char * | src, |
size_t | size | ||
) |
Duplicate string to a tmpbuf.
src | string to be duplicated |
size | maximal length to be copied |
Definition at line 111 of file tmpbuf.c.
References lumiera_tmpbuf_provide().
Referenced by lumiera_tmpbuf_tr(), and scan_word().
char* lumiera_tmpbuf_snprintf | ( | size_t | size, |
const char * | fmt, | ||
... | |||
) |
Construct a string in a tmpbuf.
size | maximal length for the string |
fmt | printf like formatstring |
... | parameters |
Definition at line 125 of file tmpbuf.c.
Referenced by lumiera_config_lookup_insert_default(), lumiera_tmpbuf_print_time(), and lumiera_tmpbuf_strcat3().
char* lumiera_tmpbuf_strcat3 | ( | const char * | str1, |
size_t | str1_len, | ||
const char * | str2, | ||
size_t | str2_len, | ||
const char * | str3, | ||
size_t | str3_len | ||
) |
Concat up to 3 strings in a tmpbuf.
str1 | first string to concat or NULL |
str1_len | how much of the first string shall be used |
str2 | second string to concat or NULL |
str2_len | how much of the second string shall be used |
str3 | third string to concat or NULL |
str3_len | how much of the third string shall be used |
Definition at line 144 of file tmpbuf.c.
References lumiera_tmpbuf_snprintf().
Referenced by lumiera_config_lookup_insert().
char* lumiera_tmpbuf_tr | ( | const char * | in, |
const char * | from, | ||
const char * | to, | ||
const char * | def | ||
) |
Translates characters in a string, similar to the shell 'tr' utility.
in | input string to be translated |
from | source character set |
to | destination character set |
def | default destination character when a character is not in the source set, when NULL then translation will abort on unknown characters and return NULL, when "" then unknown characters will be removed when set to a single character string, unknown characters will be replaced with this character |
Definition at line 156 of file tmpbuf.c.
References lumiera_tmpbuf_strndup().