size_t alloc_size;
#ifdef DEBUG
bool warn = FALSE;
+ int old_errno = errno;
#endif
if (unlikely(size == 0 || size > SSIZE_T_MAX))
had used t_buffer_get(). */
memset(PTR_OFFSET(ret, size), CLEAR_CHR,
MEM_ALIGN(size + SENTRY_COUNT) - size);
+
+ /* we rely on errno not changing. it shouldn't. */
+ i_assert(errno == old_errno);
#endif
return ret;
}
static void *pool_system_malloc(pool_t pool ATTR_UNUSED, size_t size)
{
void *mem;
+#ifdef DEBUG
+ int old_errno = errno;
+#endif
if (unlikely(size == 0 || size > SSIZE_T_MAX))
i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
i_fatal_status(FATAL_OUTOFMEM, "pool_system_malloc(%"PRIuSIZE_T
"): Out of memory", size);
}
+#ifdef DEBUG
+ /* we rely on errno not changing. it shouldn't. */
+ i_assert(errno == old_errno);
+#endif
return mem;
}
static void pool_system_free(pool_t pool ATTR_UNUSED,
void *mem ATTR_UNUSED)
{
+#ifdef DEBUG
+ int old_errno = errno;
+#endif
#if !defined(USE_GC) && defined(HAVE_MALLOC_USABLE_SIZE) && defined(DEBUG)
safe_memset(mem, CLEAR_CHR, malloc_usable_size(mem));
#endif
#ifndef USE_GC
free(mem);
#endif
+#ifdef DEBUG
+ /* we rely on errno not changing. it shouldn't. */
+ i_assert(errno == old_errno);
+#endif
}
static void *pool_system_realloc(pool_t pool ATTR_UNUSED, void *mem,
char *tmp;
unsigned int init_size;
int ret;
+#ifdef DEBUG
+ int old_errno = errno;
+#endif
VA_COPY(args2, args);
ret = vsnprintf(tmp, *size_r, format, args2);
i_assert((unsigned int)ret == *size_r-1);
}
+#ifdef DEBUG
+ /* we rely on errno not changing. it shouldn't. */
+ i_assert(errno == old_errno);
+#endif
return tmp;
}