overflows.
*/
+/* All data stack allocations - t_malloc(), t_malloc0(), t_buffer_get(),
+ t_try_realloc() etc. - preserve errno. It is therefore safe to allocate
+ temporary memory between a failing syscall and reading errno (or
+ formatting "%m"). */
+
#ifndef STATIC_CHECKER
typedef unsigned int data_stack_frame_t;
#else
/* For easy allocation of memory from default memory pool. */
+/* Like all pool allocations, i_malloc()/i_realloc()/i_free() and the
+ i_strdup*() helpers preserve errno (see mempool.h). */
+
extern pool_t default_pool;
#define i_new(type, count) p_new(default_pool, type, count)
zeroed, it will cost only a few CPU cycles and may well save some debug
time. */
+/* All pool memory operations - p_malloc(), p_realloc(), p_free() and the
+ p_new()/p_strdup*() helpers built on them - preserve errno. This means an
+ allocation between a failing syscall and reading errno (e.g. when building
+ an error string with "%m") will not clobber errno. The same guarantee holds
+ for the t_* (data stack) and i_* (default pool) allocators. */
+
typedef struct pool *pool_t;
struct pool_vfuncs {
int i_snprintf(char *dest, size_t max_chars, const char *format, ...)
ATTR_FORMAT(3, 4);
+/* The p_/t_/i_ strdup, strconcat and *printf helpers below preserve errno.
+ So this pattern is safe - errno still refers to the failed syscall when
+ "%m" is expanded:
+
+ if (syscall(...) < 0)
+ error = t_strdup_printf("syscall() failed: %m"); */
+
char *p_strdup(pool_t pool, const char *str) ATTR_MALLOC;
void *p_memdup(pool_t pool, const void *data, size_t size) ATTR_MALLOC;
/* return NULL if str = "" */