size_t base_size;
bool disable_warning;
#endif
+ bool clean_frees;
};
struct pool_block {
return &new_apool->pool;
}
+pool_t pool_alloconly_create_clean(const char *name, size_t size)
+{
+ struct alloconly_pool *apool;
+ pool_t pool;
+
+ pool = pool_alloconly_create(name, size);
+ apool = (struct alloconly_pool *)pool;
+ apool->clean_frees = TRUE;
+ return pool;
+}
+
static void pool_alloconly_destroy(struct alloconly_pool *apool)
{
void *block;
block = apool->block;
#ifdef DEBUG
safe_memset(block, CLEAR_CHR, SIZEOF_POOLBLOCK + apool->block->size);
+#else
+ if (apool->clean_frees) {
+ safe_memset(block, CLEAR_CHR,
+ SIZEOF_POOLBLOCK + apool->block->size);
+ }
#endif
+
#ifndef USE_GC
free(block);
#endif
#ifdef DEBUG
safe_memset(block, CLEAR_CHR, SIZEOF_POOLBLOCK + block->size);
+#else
+ if (apool->clean_frees) {
+ safe_memset(block, CLEAR_CHR,
+ SIZEOF_POOLBLOCK + block->size);
+ }
#endif
#ifndef USE_GC
free(block);
/* Create a new alloc-only pool. Note that `size' specifies the initial
malloc()ed block size, part of it is used internally. */
pool_t pool_alloconly_create(const char *name, size_t size);
+/* Like alloconly pool, but clear the memory before freeing it. The idea is
+ that you could allocate memory for storing sensitive information from this
+ pool, and be sure that it gets cleared from the memory when it's no longer
+ needed. */
+pool_t pool_alloconly_create_clean(const char *name, size_t size);
/* When allocating memory from returned pool, the data stack frame must be
the same as it was when calling this function. pool_unref() also checks