mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
Remove unused isc_mem_createx() function
The isc_mem_createx() function was only used in the tests to eliminate using the default flags (which as of writing this commit message was ISC_MEMFLAG_INTERNAL and ISC_MEMFLAG_FILL). This commit removes the isc_mem_createx() function from the public API.
This commit is contained in:
@@ -28,9 +28,6 @@ ISC_LANG_BEGINDECLS
|
|||||||
#define ISC_MEM_HIWATER 1
|
#define ISC_MEM_HIWATER 1
|
||||||
typedef void (*isc_mem_water_t)(void *, int);
|
typedef void (*isc_mem_water_t)(void *, int);
|
||||||
|
|
||||||
typedef void * (*isc_memalloc_t)(void *, size_t);
|
|
||||||
typedef void (*isc_memfree_t)(void *, void *);
|
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Define ISC_MEM_TRACKLINES=1 to turn on detailed tracing of memory
|
* Define ISC_MEM_TRACKLINES=1 to turn on detailed tracing of memory
|
||||||
* allocation and freeing by file and line number.
|
* allocation and freeing by file and line number.
|
||||||
@@ -123,14 +120,14 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flags for isc_mem_createx() calls.
|
* Flags for isc_mem_create() calls.
|
||||||
*/
|
*/
|
||||||
#define ISC_MEMFLAG_NOLOCK 0x00000001 /* no lock is necessary */
|
#define ISC_MEMFLAG_NOLOCK 0x00000001 /* no lock is necessary */
|
||||||
#define ISC_MEMFLAG_INTERNAL 0x00000002 /* use internal malloc */
|
#define ISC_MEMFLAG_INTERNAL 0x00000002 /* use internal malloc */
|
||||||
#define ISC_MEMFLAG_FILL 0x00000004 /* fill with pattern after alloc and frees */
|
#define ISC_MEMFLAG_FILL 0x00000004 /* fill with pattern after alloc and frees */
|
||||||
|
|
||||||
#if !ISC_MEM_USE_INTERNAL_MALLOC
|
#if !ISC_MEM_USE_INTERNAL_MALLOC
|
||||||
#define ISC_MEMFLAG_DEFAULT 0
|
#define ISC_MEMFLAG_DEFAULT 0
|
||||||
#else
|
#else
|
||||||
#define ISC_MEMFLAG_DEFAULT ISC_MEMFLAG_INTERNAL|ISC_MEMFLAG_FILL
|
#define ISC_MEMFLAG_DEFAULT ISC_MEMFLAG_INTERNAL|ISC_MEMFLAG_FILL
|
||||||
#endif
|
#endif
|
||||||
@@ -255,25 +252,9 @@ struct isc_mempool {
|
|||||||
void
|
void
|
||||||
isc_mem_create(isc_mem_t **mctxp);
|
isc_mem_create(isc_mem_t **mctxp);
|
||||||
|
|
||||||
void
|
|
||||||
isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree,
|
|
||||||
void *arg, isc_mem_t **mctxp, unsigned int flags);
|
|
||||||
|
|
||||||
/*!<
|
/*!<
|
||||||
* \brief Create a memory context.
|
* \brief Create a memory context.
|
||||||
*
|
*
|
||||||
* A memory context created using isc_mem_createx() will obtain
|
|
||||||
* memory from the system by calling 'memalloc' and 'memfree',
|
|
||||||
* passing them the argument 'arg'. A memory context created
|
|
||||||
* using isc_mem_create() will use the standard library malloc()
|
|
||||||
* and free().
|
|
||||||
*
|
|
||||||
* If ISC_MEMFLAG_NOLOCK is set in 'flags', the corresponding memory context
|
|
||||||
* will be accessed without locking. The user who creates the context must
|
|
||||||
* ensure there be no race. Since this can be a source of bug, it is generally
|
|
||||||
* inadvisable to use this flag unless the user is very sure about the race
|
|
||||||
* condition and the access to the object is highly performance sensitive.
|
|
||||||
*
|
|
||||||
* Requires:
|
* Requires:
|
||||||
* mctxp != NULL && *mctxp == NULL */
|
* mctxp != NULL && *mctxp == NULL */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
@@ -126,15 +126,17 @@ static isc_mutex_t contextslock;
|
|||||||
*/
|
*/
|
||||||
static uint64_t totallost;
|
static uint64_t totallost;
|
||||||
|
|
||||||
|
typedef void * (*isc__memalloc_t)(size_t);
|
||||||
|
typedef void (*isc__memfree_t)(void *);
|
||||||
|
|
||||||
struct isc__mem {
|
struct isc__mem {
|
||||||
isc_mem_t common;
|
isc_mem_t common;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
isc_mutex_t lock;
|
isc_mutex_t lock;
|
||||||
isc_memalloc_t memalloc;
|
isc__memalloc_t memalloc;
|
||||||
isc_memfree_t memfree;
|
isc__memfree_t memfree;
|
||||||
void * arg;
|
|
||||||
size_t max_size;
|
size_t max_size;
|
||||||
bool checkfree;
|
bool checkfree;
|
||||||
struct stats * stats;
|
struct stats * stats;
|
||||||
isc_refcount_t references;
|
isc_refcount_t references;
|
||||||
char name[16];
|
char name[16];
|
||||||
@@ -146,8 +148,8 @@ struct isc__mem {
|
|||||||
size_t maxmalloced;
|
size_t maxmalloced;
|
||||||
size_t hi_water;
|
size_t hi_water;
|
||||||
size_t lo_water;
|
size_t lo_water;
|
||||||
bool hi_called;
|
bool hi_called;
|
||||||
bool is_overmem;
|
bool is_overmem;
|
||||||
isc_mem_water_t water;
|
isc_mem_water_t water;
|
||||||
void * water_arg;
|
void * water_arg;
|
||||||
ISC_LIST(isc__mempool_t) pools;
|
ISC_LIST(isc__mempool_t) pools;
|
||||||
@@ -360,8 +362,7 @@ more_basic_blocks(isc__mem_t *ctx) {
|
|||||||
INSIST(ctx->basic_table_count <= ctx->basic_table_size);
|
INSIST(ctx->basic_table_count <= ctx->basic_table_size);
|
||||||
if (ctx->basic_table_count == ctx->basic_table_size) {
|
if (ctx->basic_table_count == ctx->basic_table_size) {
|
||||||
table_size = ctx->basic_table_size + TABLE_INCREMENT;
|
table_size = ctx->basic_table_size + TABLE_INCREMENT;
|
||||||
table = (ctx->memalloc)(ctx->arg,
|
table = (ctx->memalloc)(table_size * sizeof(unsigned char *));
|
||||||
table_size * sizeof(unsigned char *));
|
|
||||||
RUNTIME_CHECK(table != NULL);
|
RUNTIME_CHECK(table != NULL);
|
||||||
ctx->malloced += table_size * sizeof(unsigned char *);
|
ctx->malloced += table_size * sizeof(unsigned char *);
|
||||||
if (ctx->malloced > ctx->maxmalloced)
|
if (ctx->malloced > ctx->maxmalloced)
|
||||||
@@ -370,7 +371,7 @@ more_basic_blocks(isc__mem_t *ctx) {
|
|||||||
memmove(table, ctx->basic_table,
|
memmove(table, ctx->basic_table,
|
||||||
ctx->basic_table_size *
|
ctx->basic_table_size *
|
||||||
sizeof(unsigned char *));
|
sizeof(unsigned char *));
|
||||||
(ctx->memfree)(ctx->arg, ctx->basic_table);
|
(ctx->memfree)(ctx->basic_table);
|
||||||
ctx->malloced -= ctx->basic_table_size *
|
ctx->malloced -= ctx->basic_table_size *
|
||||||
sizeof(unsigned char *);
|
sizeof(unsigned char *);
|
||||||
}
|
}
|
||||||
@@ -378,7 +379,7 @@ more_basic_blocks(isc__mem_t *ctx) {
|
|||||||
ctx->basic_table_size = table_size;
|
ctx->basic_table_size = table_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = (ctx->memalloc)(ctx->arg, NUM_BASIC_BLOCKS * ctx->mem_target);
|
tmp = (ctx->memalloc)(NUM_BASIC_BLOCKS * ctx->mem_target);
|
||||||
RUNTIME_CHECK(tmp != NULL);
|
RUNTIME_CHECK(tmp != NULL);
|
||||||
ctx->total += NUM_BASIC_BLOCKS * ctx->mem_target;;
|
ctx->total += NUM_BASIC_BLOCKS * ctx->mem_target;;
|
||||||
ctx->basic_table[ctx->basic_table_count] = tmp;
|
ctx->basic_table[ctx->basic_table_count] = tmp;
|
||||||
@@ -471,7 +472,7 @@ mem_getunlocked(isc__mem_t *ctx, size_t size) {
|
|||||||
/*
|
/*
|
||||||
* memget() was called on something beyond our upper limit.
|
* memget() was called on something beyond our upper limit.
|
||||||
*/
|
*/
|
||||||
ret = (ctx->memalloc)(ctx->arg, size);
|
ret = (ctx->memalloc)(size);
|
||||||
RUNTIME_CHECK(ret != NULL);
|
RUNTIME_CHECK(ret != NULL);
|
||||||
ctx->total += size;
|
ctx->total += size;
|
||||||
ctx->inuse += size;
|
ctx->inuse += size;
|
||||||
@@ -550,7 +551,7 @@ mem_putunlocked(isc__mem_t *ctx, void *mem, size_t size) {
|
|||||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0))
|
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0))
|
||||||
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
||||||
|
|
||||||
(ctx->memfree)(ctx->arg, mem);
|
(ctx->memfree)(mem);
|
||||||
INSIST(ctx->stats[ctx->max_size].gets != 0U);
|
INSIST(ctx->stats[ctx->max_size].gets != 0U);
|
||||||
ctx->stats[ctx->max_size].gets--;
|
ctx->stats[ctx->max_size].gets--;
|
||||||
INSIST(size <= ctx->inuse);
|
INSIST(size <= ctx->inuse);
|
||||||
@@ -594,7 +595,7 @@ mem_get(isc__mem_t *ctx, size_t size) {
|
|||||||
#if ISC_MEM_CHECKOVERRUN
|
#if ISC_MEM_CHECKOVERRUN
|
||||||
size += 1;
|
size += 1;
|
||||||
#endif
|
#endif
|
||||||
ret = (ctx->memalloc)(ctx->arg, size);
|
ret = (ctx->memalloc)(size);
|
||||||
RUNTIME_CHECK(ret != NULL);
|
RUNTIME_CHECK(ret != NULL);
|
||||||
|
|
||||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
|
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
|
||||||
@@ -623,7 +624,7 @@ mem_put(isc__mem_t *ctx, void *mem, size_t size) {
|
|||||||
#endif
|
#endif
|
||||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0))
|
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0))
|
||||||
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
||||||
(ctx->memfree)(ctx->arg, mem);
|
(ctx->memfree)(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -678,9 +679,8 @@ mem_putstats(isc__mem_t *ctx, void *ptr, size_t size) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
default_memalloc(void *arg, size_t size) {
|
default_memalloc(size_t size) {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
UNUSED(arg);
|
|
||||||
|
|
||||||
ptr = malloc(size);
|
ptr = malloc(size);
|
||||||
|
|
||||||
@@ -709,8 +709,7 @@ default_memalloc(void *arg, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
default_memfree(void *arg, void *ptr) {
|
default_memfree(void *ptr) {
|
||||||
UNUSED(arg);
|
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,27 +720,19 @@ initialize_action(void) {
|
|||||||
totallost = 0;
|
totallost = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void
|
||||||
* Public.
|
mem_create(isc_mem_t **ctxp, unsigned int flags)
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
|
||||||
isc_mem_t **ctxp, unsigned int flags)
|
|
||||||
{
|
{
|
||||||
isc__mem_t *ctx;
|
isc__mem_t *ctx;
|
||||||
|
|
||||||
REQUIRE(ctxp != NULL && *ctxp == NULL);
|
REQUIRE(ctxp != NULL && *ctxp == NULL);
|
||||||
REQUIRE(memalloc != NULL);
|
|
||||||
REQUIRE(memfree != NULL);
|
|
||||||
|
|
||||||
STATIC_ASSERT((ALIGNMENT_SIZE & (ALIGNMENT_SIZE - 1)) == 0,
|
STATIC_ASSERT((ALIGNMENT_SIZE & (ALIGNMENT_SIZE - 1)) == 0,
|
||||||
"wrong alignment size");
|
"wrong alignment size");
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
|
||||||
|
|
||||||
ctx = (memalloc)(arg, sizeof(*ctx));
|
ctx = (default_memalloc)(sizeof(*ctx));
|
||||||
RUNTIME_CHECK(ctx != NULL);
|
|
||||||
|
|
||||||
if ((flags & ISC_MEMFLAG_NOLOCK) == 0) {
|
if ((flags & ISC_MEMFLAG_NOLOCK) == 0) {
|
||||||
isc_mutex_init(&ctx->lock);
|
isc_mutex_init(&ctx->lock);
|
||||||
@@ -766,9 +757,8 @@ isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
|||||||
ctx->common.impmagic = MEM_MAGIC;
|
ctx->common.impmagic = MEM_MAGIC;
|
||||||
ctx->common.magic = ISCAPI_MCTX_MAGIC;
|
ctx->common.magic = ISCAPI_MCTX_MAGIC;
|
||||||
ctx->common.methods = (isc_memmethods_t *)&memmethods;
|
ctx->common.methods = (isc_memmethods_t *)&memmethods;
|
||||||
ctx->memalloc = memalloc;
|
ctx->memalloc = default_memalloc;
|
||||||
ctx->memfree = memfree;
|
ctx->memfree = default_memfree;
|
||||||
ctx->arg = arg;
|
|
||||||
ctx->stats = NULL;
|
ctx->stats = NULL;
|
||||||
ctx->checkfree = true;
|
ctx->checkfree = true;
|
||||||
#if ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
@@ -785,8 +775,7 @@ isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
|||||||
ctx->lowest = NULL;
|
ctx->lowest = NULL;
|
||||||
ctx->highest = NULL;
|
ctx->highest = NULL;
|
||||||
|
|
||||||
ctx->stats = (memalloc)(arg,
|
ctx->stats = (ctx->memalloc)((ctx->max_size+1) * sizeof(struct stats));
|
||||||
(ctx->max_size+1) * sizeof(struct stats));
|
|
||||||
RUNTIME_CHECK(ctx->stats != NULL);
|
RUNTIME_CHECK(ctx->stats != NULL);
|
||||||
|
|
||||||
memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof(struct stats));
|
memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof(struct stats));
|
||||||
@@ -795,7 +784,7 @@ isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
|||||||
|
|
||||||
if ((flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
if ((flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||||
ctx->mem_target = DEF_MEM_TARGET;
|
ctx->mem_target = DEF_MEM_TARGET;
|
||||||
ctx->freelists = (memalloc)(arg, ctx->max_size *
|
ctx->freelists = (ctx->memalloc)(ctx->max_size *
|
||||||
sizeof(element *));
|
sizeof(element *));
|
||||||
RUNTIME_CHECK(ctx->freelists != NULL);
|
RUNTIME_CHECK(ctx->freelists != NULL);
|
||||||
memset(ctx->freelists, 0,
|
memset(ctx->freelists, 0,
|
||||||
@@ -808,7 +797,7 @@ isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
|||||||
if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0)) {
|
if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0)) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
ctx->debuglist = (memalloc)(arg, (DEBUG_TABLE_COUNT *
|
ctx->debuglist = (ctx->memalloc)((DEBUG_TABLE_COUNT *
|
||||||
sizeof(debuglist_t)));
|
sizeof(debuglist_t)));
|
||||||
RUNTIME_CHECK(ctx->debuglist != NULL);
|
RUNTIME_CHECK(ctx->debuglist != NULL);
|
||||||
for (i = 0; i < DEBUG_TABLE_COUNT; i++)
|
for (i = 0; i < DEBUG_TABLE_COUNT; i++)
|
||||||
@@ -825,6 +814,10 @@ isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
|||||||
*ctxp = (isc_mem_t *)ctx;
|
*ctxp = (isc_mem_t *)ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public.
|
||||||
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy(isc__mem_t *ctx) {
|
destroy(isc__mem_t *ctx) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -856,7 +849,7 @@ destroy(isc__mem_t *ctx) {
|
|||||||
ctx->malloced -= sizeof(*dl);
|
ctx->malloced -= sizeof(*dl);
|
||||||
}
|
}
|
||||||
|
|
||||||
(ctx->memfree)(ctx->arg, ctx->debuglist);
|
(ctx->memfree)(ctx->debuglist);
|
||||||
ctx->malloced -= DEBUG_TABLE_COUNT * sizeof(debuglist_t);
|
ctx->malloced -= DEBUG_TABLE_COUNT * sizeof(debuglist_t);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -877,18 +870,18 @@ destroy(isc__mem_t *ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(ctx->memfree)(ctx->arg, ctx->stats);
|
(ctx->memfree)(ctx->stats);
|
||||||
ctx->malloced -= (ctx->max_size+1) * sizeof(struct stats);
|
ctx->malloced -= (ctx->max_size+1) * sizeof(struct stats);
|
||||||
|
|
||||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||||
for (i = 0; i < ctx->basic_table_count; i++) {
|
for (i = 0; i < ctx->basic_table_count; i++) {
|
||||||
(ctx->memfree)(ctx->arg, ctx->basic_table[i]);
|
(ctx->memfree)(ctx->basic_table[i]);
|
||||||
ctx->malloced -= NUM_BASIC_BLOCKS * ctx->mem_target;
|
ctx->malloced -= NUM_BASIC_BLOCKS * ctx->mem_target;
|
||||||
}
|
}
|
||||||
(ctx->memfree)(ctx->arg, ctx->freelists);
|
(ctx->memfree)(ctx->freelists);
|
||||||
ctx->malloced -= ctx->max_size * sizeof(element *);
|
ctx->malloced -= ctx->max_size * sizeof(element *);
|
||||||
if (ctx->basic_table != NULL) {
|
if (ctx->basic_table != NULL) {
|
||||||
(ctx->memfree)(ctx->arg, ctx->basic_table);
|
(ctx->memfree)(ctx->basic_table);
|
||||||
ctx->malloced -= ctx->basic_table_size *
|
ctx->malloced -= ctx->basic_table_size *
|
||||||
sizeof(unsigned char *);
|
sizeof(unsigned char *);
|
||||||
}
|
}
|
||||||
@@ -899,7 +892,7 @@ destroy(isc__mem_t *ctx) {
|
|||||||
ctx->malloced -= sizeof(*ctx);
|
ctx->malloced -= sizeof(*ctx);
|
||||||
if (ctx->checkfree)
|
if (ctx->checkfree)
|
||||||
INSIST(ctx->malloced == 0);
|
INSIST(ctx->malloced == 0);
|
||||||
(ctx->memfree)(ctx->arg, ctx);
|
(ctx->memfree)(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2364,8 +2357,7 @@ isc_mem_renderjson(void *memobj0) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc_mem_create(isc_mem_t **mctxp) {
|
isc_mem_create(isc_mem_t **mctxp) {
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
mem_create(mctxp, isc_mem_defaultflags);
|
||||||
NULL, mctxp, isc_mem_defaultflags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
@@ -16,7 +16,10 @@ VERSION=@BIND9_VERSION@
|
|||||||
@BIND9_MAKE_INCLUDES@
|
@BIND9_MAKE_INCLUDES@
|
||||||
|
|
||||||
CINCLUDES = -I. -Iinclude ${ISC_INCLUDES} \
|
CINCLUDES = -I. -Iinclude ${ISC_INCLUDES} \
|
||||||
${OPENSSL_CFLAGS} @CMOCKA_CFLAGS@
|
${OPENSSL_CFLAGS} @CMOCKA_CFLAGS@ \
|
||||||
|
${JSON_C_CFLAGS} \
|
||||||
|
${LIBXML2_CFLAGS} \
|
||||||
|
${ZLIB_CFLAGS}
|
||||||
CDEFINES = -DTESTS="\"${top_builddir}/lib/isc/tests/\""
|
CDEFINES = -DTESTS="\"${top_builddir}/lib/isc/tests/\""
|
||||||
|
|
||||||
ISCLIBS = ../libisc.@A@ ${OPENSSL_LIBS} ${JSON_C_LIBS} ${LIBXML2_LIBS}
|
ISCLIBS = ../libisc.@A@ ${OPENSSL_LIBS} ${JSON_C_LIBS} ${LIBXML2_LIBS}
|
||||||
|
@@ -31,21 +31,6 @@
|
|||||||
#include <isc/string.h>
|
#include <isc/string.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
|
||||||
static void *
|
|
||||||
default_memalloc(void *arg, size_t size) {
|
|
||||||
UNUSED(arg);
|
|
||||||
if (size == 0U) {
|
|
||||||
size = 1;
|
|
||||||
}
|
|
||||||
return (malloc(size));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
default_memfree(void *arg, void *ptr) {
|
|
||||||
UNUSED(arg);
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_ht_full(int bits, uintptr_t count) {
|
test_ht_full(int bits, uintptr_t count) {
|
||||||
isc_ht_t *ht = NULL;
|
isc_ht_t *ht = NULL;
|
||||||
@@ -53,8 +38,7 @@ test_ht_full(int bits, uintptr_t count) {
|
|||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
uintptr_t i;
|
uintptr_t i;
|
||||||
|
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&mctx);
|
||||||
NULL, &mctx, 0);
|
|
||||||
|
|
||||||
result = isc_ht_init(&ht, mctx, bits);
|
result = isc_ht_init(&ht, mctx, bits);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -206,8 +190,7 @@ test_ht_iterator() {
|
|||||||
unsigned char key[16];
|
unsigned char key[16];
|
||||||
size_t tksize;
|
size_t tksize;
|
||||||
|
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&mctx);
|
||||||
NULL, &mctx, 0);
|
|
||||||
|
|
||||||
result = isc_ht_init(&ht, mctx, 16);
|
result = isc_ht_init(&ht, mctx, 16);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
@@ -50,21 +50,6 @@ _setup(void **state) {
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
|
||||||
default_memalloc(void *arg, size_t size) {
|
|
||||||
UNUSED(arg);
|
|
||||||
if (size == 0U) {
|
|
||||||
size = 1;
|
|
||||||
}
|
|
||||||
return (malloc(size));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
default_memfree(void *arg, void *ptr) {
|
|
||||||
UNUSED(arg);
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_teardown(void **state) {
|
_teardown(void **state) {
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
@@ -168,9 +153,7 @@ isc_mem_test(void **state) {
|
|||||||
|
|
||||||
isc_mem_destroy(&localmctx);
|
isc_mem_destroy(&localmctx);
|
||||||
|
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&localmctx);
|
||||||
NULL, &localmctx,
|
|
||||||
ISC_MEMFLAG_FILL | ISC_MEMFLAG_INTERNAL);
|
|
||||||
|
|
||||||
result = isc_mempool_create(localmctx, 2, &mp1);
|
result = isc_mempool_create(localmctx, 2, &mp1);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
@@ -198,8 +181,7 @@ isc_mem_total_test(void **state) {
|
|||||||
|
|
||||||
/* Local alloc, free */
|
/* Local alloc, free */
|
||||||
mctx2 = NULL;
|
mctx2 = NULL;
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&mctx2);
|
||||||
NULL, &mctx2, 0);
|
|
||||||
|
|
||||||
before = isc_mem_total(mctx2);
|
before = isc_mem_total(mctx2);
|
||||||
|
|
||||||
@@ -247,8 +229,7 @@ isc_mem_inuse_test(void **state) {
|
|||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
mctx2 = NULL;
|
mctx2 = NULL;
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&mctx2);
|
||||||
NULL, &mctx2, 0);
|
|
||||||
|
|
||||||
before = isc_mem_inuse(mctx2);
|
before = isc_mem_inuse(mctx2);
|
||||||
ptr = isc_mem_allocate(mctx2, 1024000);
|
ptr = isc_mem_allocate(mctx2, 1024000);
|
||||||
@@ -278,8 +259,7 @@ isc_mem_noflags_test(void **state) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&mctx2);
|
||||||
NULL, &mctx2, 0);
|
|
||||||
isc_mem_debugging = 0;
|
isc_mem_debugging = 0;
|
||||||
ptr = isc_mem_get(mctx2, 2048);
|
ptr = isc_mem_get(mctx2, 2048);
|
||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
@@ -324,8 +304,7 @@ isc_mem_recordflag_test(void **state) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&mctx2);
|
||||||
NULL, &mctx2, 0);
|
|
||||||
ptr = isc_mem_get(mctx2, 2048);
|
ptr = isc_mem_get(mctx2, 2048);
|
||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
isc__mem_printactive(mctx2, f);
|
isc__mem_printactive(mctx2, f);
|
||||||
@@ -368,8 +347,7 @@ isc_mem_traceflag_test(void **state) {
|
|||||||
|
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
|
|
||||||
isc_mem_createx(default_memalloc, default_memfree,
|
isc_mem_create(&mctx2);
|
||||||
NULL, &mctx2, 0);
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
|
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
|
||||||
ptr = isc_mem_get(mctx2, 2048);
|
ptr = isc_mem_get(mctx2, 2048);
|
||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
|
@@ -348,7 +348,6 @@ isc_md
|
|||||||
isc_mem_attach
|
isc_mem_attach
|
||||||
isc_mem_checkdestroyed
|
isc_mem_checkdestroyed
|
||||||
isc_mem_create
|
isc_mem_create
|
||||||
isc_mem_createx
|
|
||||||
isc_mem_destroy
|
isc_mem_destroy
|
||||||
isc_mem_detach
|
isc_mem_detach
|
||||||
isc_mem_getname
|
isc_mem_getname
|
||||||
|
Reference in New Issue
Block a user