89 buf->
idx = (buf->
idx + 1) & 0x3f;
94 buf->
sizes[buf->
idx] = (size+4*
sizeof(long)) & ~(4*
sizeof(long)-1);
104 size_t len = strlen (src);
105 len = len > size ? size : len;
108 strncpy (buf, src, len);
120 va_start (args, fmt);
121 size_t len = vsnprintf (
NULL, 0, fmt, args);
124 len = len > size ? size : len;
126 va_start (args, fmt);
127 vsnprintf (buf, len+1, fmt, args);
136 const char* str2,
size_t str2_len,
137 const char* str3,
size_t str3_len)
140 str1?str1_len:0, str1?str1:
"", str1?
".":
"",
141 str2?str2_len:0, str2?str2:
"",
142 str3?
".":
"", str3?str3_len:0, str3?str3:
"");
149 REQUIRE (strlen (from) == strlen (to),
"from and to character set must have equal length");
155 for (wpos = rpos = ret; *rpos; ++rpos, ++wpos)
157 char* found = strchr (from, *rpos);
159 *wpos = to[found-from];
void * lumiera_calloc(size_t n, size_t size)
Allocate cleared memory for an array.
void * lumiera_malloc(size_t size)
Allocate memory.
Portable and safe wrappers around some C-Lib functions.
static void lumiera_free(void *mem)
Free previously allocated memory.
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.
char * lumiera_tmpbuf_strndup(const char *src, size_t size)
Duplicate string to a tmpbuf.
static pthread_once_t lumiera_tmpbuf_tls_once
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.
char * lumiera_tmpbuf_snprintf(size_t size, const char *fmt,...)
Construct a string in a tmpbuf.
void lumiera_tmpbuf_freeall(void)
free all buffers associated with this thread.
static pthread_key_t lumiera_tmpbuf_tls_key
void * lumiera_tmpbuf_provide(size_t size)
Query a thread local tmpbuf.
static void lumiera_tmpbuf_destroy(void *buf)
static void lumiera_tmpbuf_init(void)
Round robin temporary buffers.
#define LUMIERA_TMPBUF_NUM
Number of buffers in the ring This also defines how many concurent buffers can be in use in one threa...