fi
AM_CONDITIONAL(HAVE_SYSTEMD, test "$systemdsystemunitdir" != "")
-AC_ARG_WITH(gc,
-AS_HELP_STRING([--with-gc], [Use Boehm garbage collector]),
- TEST_WITH(gc, $withval),
- want_gc=no)
-
DC_DOVECOT_MODULEDIR
AC_ARG_WITH(docs,
DOVECOT_SSL
-DOVECOT_GC
-
dnl **
dnl ** userdb and passdb checks
Only real solution is to use garbage collector, but it's not possible to
write a portable GC without radical changes in how you write code.
-I've added support for Boehm GC, but it doesn't seem to be working very
-well currently. In any case I'd rather not make it required.
-
There are a few ways to avoid most free() calls however: data stack and
memory pools.
+++ /dev/null
-dnl **
-dnl ** Garbage Collector
-dnl **
-
-AC_DEFUN([DOVECOT_GC], [
- if test $want_gc != no; then
- AC_CHECK_LIB(gc, GC_malloc, [
- AC_CHECK_HEADERS(gc/gc.h gc.h)
- AC_DEFINE(USE_GC,, [Define if you want to use Boehm GC])
- LIBS="$LIBS -lgc"
- ], [
- if test $want_gc = yes; then
- AC_ERROR([Can't build with GC: libgc not found])
- fi
- ])
- fi
-])
#include "data-stack.h"
-#ifdef HAVE_GC_GC_H
-# include <gc/gc.h>
-#elif defined (HAVE_GC_H)
-# include <gc.h>
-#endif
-
/* Initial stack size - this should be kept in a size that doesn't exceed
in a normal use to avoid extra malloc()ing. */
#ifdef DEBUG
frame_pos = 0;
if (unused_frame_blocks == NULL) {
/* allocate new block */
-#ifndef USE_GC
frame_block = calloc(sizeof(*frame_block), 1);
-#else
- frame_block = GC_malloc(sizeof(*frame_block));
-#endif
if (frame_block == NULL) {
i_fatal_status(FATAL_OUTOFMEM,
"t_push(): Out of memory");
memset(STACK_BLOCK_DATA(block), CLEAR_CHR, block->size);
if (unused_block == NULL || block->size > unused_block->size) {
-#ifndef USE_GC
free(unused_block);
-#endif
unused_block = block;
} else {
-#ifndef USE_GC
if (block != &outofmem_area.block)
free(block);
-#endif
}
block = next;
/* nearest_power() returns 2^n values, so alloc_size can't be
anywhere close to SIZE_MAX */
-#ifndef USE_GC
block = malloc(SIZEOF_MEMBLOCK + alloc_size);
-#else
- block = GC_malloc(SIZEOF_MEMBLOCK + alloc_size);
-#endif
if (unlikely(block == NULL)) {
if (outofmem) {
if (min_size > outofmem_area.block.left)
frame_pos != BLOCK_FRAME_COUNT-1)
i_panic("Missing t_pop() call");
-#ifndef USE_GC
while (unused_frame_blocks != NULL) {
struct stack_frame_block *frame_block = unused_frame_blocks;
unused_frame_blocks = unused_frame_blocks->prev;
free(current_block);
free(unused_block);
-#endif
unused_frame_blocks = NULL;
current_block = NULL;
unused_block = NULL;
#include "mempool.h"
-#ifdef HAVE_GC_GC_H
-# include <gc/gc.h>
-#elif defined (HAVE_GC_H)
-# include <gc.h>
-#endif
-
#define MAX_ALLOC_SIZE SSIZE_T_MAX
struct alloconly_pool {
}
#endif
-#ifndef USE_GC
free(block);
-#endif
}
static const char *pool_alloconly_get_name(pool_t pool ATTR_UNUSED)
#endif
}
-#ifndef USE_GC
block = calloc(size, 1);
-#else
- block = GC_malloc(size);
-#endif
if (unlikely(block == NULL)) {
i_fatal_status(FATAL_OUTOFMEM, "block_alloc(%"PRIuSIZE_T
"): Out of memory", size);
SIZEOF_POOLBLOCK + block->size);
}
#endif
-#ifndef USE_GC
free(block);
-#endif
}
/* clear the first block */
# include <malloc.h> /* Linux */
#endif
-#ifdef HAVE_GC_GC_H
-# include <gc/gc.h>
-#elif defined (HAVE_GC_H)
-# include <gc.h>
-#endif
-
#define CLEAR_CHR 0xde
static const char *pool_system_get_name(pool_t pool);
if (unlikely(size == 0 || size > SSIZE_T_MAX))
i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
-#ifndef USE_GC
mem = calloc(size, 1);
-#else
- mem = GC_malloc(size);
-#endif
if (unlikely(mem == NULL)) {
i_fatal_status(FATAL_OUTOFMEM, "pool_system_malloc(%"PRIuSIZE_T
"): Out of memory", size);
#ifdef DEBUG
int old_errno = errno;
#endif
-#if !defined(USE_GC) && defined(HAVE_MALLOC_USABLE_SIZE) && defined(DEBUG)
+#if 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);
i_assert(old_size == 0);
return pool_system_malloc(pool, new_size);
}
-#if !defined(USE_GC) && defined(HAVE_MALLOC_USABLE_SIZE)
+#if defined(HAVE_MALLOC_USABLE_SIZE)
i_assert(old_size == (size_t)-1 || mem == NULL ||
old_size <= malloc_usable_size(mem));
#endif
-#ifndef USE_GC
mem = realloc(mem, new_size);
-#else
- mem = GC_realloc(mem, new_size);
-#endif
if (unlikely(mem == NULL)) {
i_fatal_status(FATAL_OUTOFMEM, "pool_system_realloc(%"PRIuSIZE_T
"): Out of memory", new_size);