12#if !defined(COINUTILS_MEMPOOL_MAXPOOLED)
13#define COINUTILS_MEMPOOL_MAXPOOLED -1
16#if (COINUTILS_MEMPOOL_MAXPOOLED >= 0)
18#ifndef COINUTILS_MEMPOOL_ALIGNMENT
19#define COINUTILS_MEMPOOL_ALIGNMENT 16
33#if (COINUTILS_MEMPOOL_ALIGNMENT == 16)
34static const std::size_t CoinAllocPtrShift = 4;
35static const std::size_t CoinAllocRoundMask = ~((std::size_t)15);
36#elif (COINUTILS_MEMPOOL_ALIGNMENT == 8)
37static const std::size_t CoinAllocPtrShift = 3;
38static const std::size_t CoinAllocRoundMask = ~((std::size_t)7);
40#error "COINUTILS_MEMPOOL_ALIGNMENT must be defined as 8 or 16 (or this code needs to be changed :-)"
45#ifndef COIN_MEMPOOL_SAVE_BLOCKHEADS
46#define COIN_MEMPOOL_SAVE_BLOCKHEADS 0
53#if (COIN_MEMPOOL_SAVE_BLOCKHEADS == 1)
55 std::size_t block_num;
56 std::size_t max_block_num;
58#if defined(COINUTILS_PTHREADS) && (COINUTILS_PTHREAD == 1)
59 pthread_mutex_t mutex_;
73#if defined(COINUTILS_PTHREADS) && (COINUTILS_PTHREAD == 1)
74 pthread_mutex_lock(&mutex_);
79#if defined(COINUTILS_PTHREADS) && (COINUTILS_PTHREAD == 1)
80 pthread_mutex_unlock(&mutex_);
91 char **pp = (
char **)p;
122 inline void *
alloc(
const std::size_t n)
125 return std::malloc(n);
131 p =
static_cast< char *
>(std::malloc(to_alloc));
133 throw std::bad_alloc();
135 pool =
pool_ + (to_alloc >> CoinAllocPtrShift);
164#if defined(COINUTILS_MEMPOOL_OVERRIDE_NEW) && (COINUTILS_MEMPOOL_OVERRIDE_NEW == 1)
165void *
operator new(std::size_t size)
throw(std::bad_alloc);
166void *
operator new[](std::size_t)
throw(std::bad_alloc);
167void operator delete(
void *)
throw();
168void operator delete[](
void *)
throw();
169void *
operator new(std::size_t,
const std::nothrow_t &)
throw();
170void *
operator new[](std::size_t,
const std::nothrow_t &)
throw();
171void operator delete(
void *,
const std::nothrow_t &)
throw();
172void operator delete[](
void *,
const std::nothrow_t &)
throw();
#define COINUTILS_MEMPOOL_ALIGNMENT
void * alloc(const std::size_t n)
const std::size_t entry_size_
CoinMempool & operator=(const CoinMempool &)
CoinMempool(const CoinMempool &)
char * allocate_new_block()
CoinMempool(std::size_t size=0)