mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
removed the unused and undocumented functions
isc_mem_preallocate(), isc_mem_valid(), isc_mem_setsplit(), and isc_mem_restore()
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: mem.h,v 1.47 2001/02/09 18:51:20 gson Exp $ */
|
||||
/* $Id: mem.h,v 1.48 2001/02/09 19:05:23 gson Exp $ */
|
||||
|
||||
#ifndef ISC_MEM_H
|
||||
#define ISC_MEM_H 1
|
||||
@@ -208,18 +208,11 @@ isc_result_t isc_mem_ondestroy(isc_mem_t *ctx,
|
||||
* been successfully destroyed.
|
||||
*/
|
||||
|
||||
isc_result_t isc_mem_preallocate(isc_mem_t *);
|
||||
/* XXX */
|
||||
|
||||
void isc_mem_stats(isc_mem_t *mctx, FILE *out);
|
||||
/*
|
||||
* Print memory usage statistics for 'mctx' on the stream 'out'.
|
||||
*/
|
||||
|
||||
|
||||
isc_boolean_t isc_mem_valid(isc_mem_t *, void *);
|
||||
/* XXX */
|
||||
|
||||
void isc_mem_setdestroycheck(isc_mem_t *mctx,
|
||||
isc_boolean_t on);
|
||||
/*
|
||||
@@ -227,9 +220,6 @@ void isc_mem_setdestroycheck(isc_mem_t *mctx,
|
||||
* destroyed and abort the program if any are present.
|
||||
*/
|
||||
|
||||
void isc_mem_setsplit(isc_mem_t *, isc_boolean_t);
|
||||
/* XXX */
|
||||
|
||||
void isc_mem_setquota(isc_mem_t *, size_t);
|
||||
size_t isc_mem_getquota(isc_mem_t *);
|
||||
/*
|
||||
@@ -245,9 +235,6 @@ size_t isc_mem_inuse(isc_mem_t *mctx);
|
||||
* allocated from the system but not yet used.
|
||||
*/
|
||||
|
||||
isc_result_t isc_mem_restore(isc_mem_t *);
|
||||
/* XXX */
|
||||
|
||||
void
|
||||
isc_mem_setwater(isc_mem_t *mctx, isc_mem_water_t water, void *water_arg,
|
||||
size_t hiwater, size_t lowater);
|
||||
|
162
lib/isc/mem.c
162
lib/isc/mem.c
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: mem.c,v 1.82 2001/02/09 18:51:18 gson Exp $ */
|
||||
/* $Id: mem.c,v 1.83 2001/02/09 19:05:22 gson Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -133,7 +133,6 @@ struct isc_mem {
|
||||
unsigned int basic_table_size;
|
||||
unsigned char * lowest;
|
||||
unsigned char * highest;
|
||||
isc_boolean_t trysplit;
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
@@ -304,71 +303,6 @@ quantize(size_t size) {
|
||||
return ((size + ALIGNMENT_SIZE - 1) & (~(ALIGNMENT_SIZE - 1)));
|
||||
}
|
||||
|
||||
static inline void
|
||||
split(isc_mem_t *ctx, size_t size, size_t new_size) {
|
||||
unsigned char *ptr;
|
||||
size_t remaining_size;
|
||||
|
||||
/*
|
||||
* Unlink a frag of size 'size'.
|
||||
*/
|
||||
ptr = (unsigned char *)ctx->freelists[size];
|
||||
ctx->freelists[size] = ctx->freelists[size]->next;
|
||||
ctx->stats[size].freefrags--;
|
||||
|
||||
/*
|
||||
* Create a frag of size 'new_size' and link it in.
|
||||
*/
|
||||
((element *)ptr)->next = ctx->freelists[new_size];
|
||||
ctx->freelists[new_size] = (element *)ptr;
|
||||
ctx->stats[new_size].freefrags++;
|
||||
|
||||
/*
|
||||
* Create a frag of size 'size - new_size' and link it in.
|
||||
*/
|
||||
remaining_size = size - new_size;
|
||||
ptr += new_size;
|
||||
((element *)ptr)->next = ctx->freelists[remaining_size];
|
||||
ctx->freelists[remaining_size] = (element *)ptr;
|
||||
ctx->stats[remaining_size].freefrags++;
|
||||
}
|
||||
|
||||
static inline isc_boolean_t
|
||||
try_split(isc_mem_t *ctx, size_t new_size) {
|
||||
size_t i, doubled_size;
|
||||
|
||||
if (!ctx->trysplit)
|
||||
return (ISC_FALSE);
|
||||
|
||||
/*
|
||||
* Try splitting a frag that's at least twice as big as the size
|
||||
* we want.
|
||||
*/
|
||||
doubled_size = new_size * 2;
|
||||
for (i = doubled_size;
|
||||
i < ctx->max_size;
|
||||
i += ALIGNMENT_SIZE) {
|
||||
if (ctx->freelists[i] != NULL) {
|
||||
split(ctx, i, new_size);
|
||||
return (ISC_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No luck. Try splitting any frag bigger than the size we need.
|
||||
*/
|
||||
for (i = new_size + ALIGNMENT_SIZE;
|
||||
i < doubled_size;
|
||||
i += ALIGNMENT_SIZE) {
|
||||
if (ctx->freelists[i] != NULL) {
|
||||
split(ctx, i, new_size);
|
||||
return (ISC_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return (ISC_FALSE);
|
||||
}
|
||||
|
||||
static inline isc_boolean_t
|
||||
more_basic_blocks(isc_mem_t *ctx) {
|
||||
void *new;
|
||||
@@ -455,11 +389,7 @@ more_frags(isc_mem_t *ctx, size_t new_size) {
|
||||
/*
|
||||
* XXXRTH "At quota" notification here.
|
||||
*/
|
||||
/*
|
||||
* Maybe we can split one of our existing
|
||||
* list frags.
|
||||
*/
|
||||
return (try_split(ctx, new_size));
|
||||
return (ISC_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,7 +722,6 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto error;
|
||||
}
|
||||
ctx->trysplit = ISC_FALSE;
|
||||
memset(ctx->freelists, 0,
|
||||
ctx->max_size * sizeof (element *));
|
||||
ctx->basic_blocks = NULL;
|
||||
@@ -1007,17 +936,6 @@ isc_mem_ondestroy(isc_mem_t *ctx, isc_task_t *task, isc_event_t **event) {
|
||||
}
|
||||
|
||||
|
||||
isc_result_t
|
||||
isc_mem_restore(isc_mem_t *ctx) {
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_mutex_init(&ctx->lock);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
ctx->magic = 0;
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
void *
|
||||
isc__mem_get(isc_mem_t *ctx, size_t size FLARG) {
|
||||
void *ptr;
|
||||
@@ -1078,39 +996,6 @@ isc__mem_put(isc_mem_t *ctx, void *ptr, size_t size FLARG)
|
||||
}
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_mem_preallocate(isc_mem_t *ctx) {
|
||||
#if ISC_MEM_USE_INTERNAL_MALLOC
|
||||
|
||||
size_t i;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
void *ptr;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
LOCK(&ctx->lock);
|
||||
|
||||
for (i = 0; i < ctx->max_size; i += ALIGNMENT_SIZE) {
|
||||
ptr = mem_getunlocked(ctx, i);
|
||||
if (ptr == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
break;
|
||||
}
|
||||
mem_putunlocked(ctx, ptr, i);
|
||||
}
|
||||
|
||||
UNLOCK(&ctx->lock);
|
||||
|
||||
return (result);
|
||||
|
||||
#else /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
UNUSED(ctx);
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
}
|
||||
|
||||
void
|
||||
isc_mem_stats(isc_mem_t *ctx, FILE *out) {
|
||||
size_t i;
|
||||
@@ -1212,33 +1097,6 @@ isc_mem_stats(isc_mem_t *ctx, FILE *out) {
|
||||
UNLOCK(&ctx->lock);
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
isc_mem_valid(isc_mem_t *ctx, void *ptr) {
|
||||
#if ISC_MEM_USE_INTERNAL_MALLOC
|
||||
|
||||
unsigned char *cp = ptr;
|
||||
isc_boolean_t result = ISC_FALSE;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
|
||||
LOCK(&ctx->lock);
|
||||
|
||||
if (ctx->lowest != NULL && cp >= ctx->lowest && cp <= ctx->highest)
|
||||
result = ISC_TRUE;
|
||||
|
||||
UNLOCK(&ctx->lock);
|
||||
|
||||
return (result);
|
||||
|
||||
#else /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
UNUSED(ctx);
|
||||
UNUSED(ptr);
|
||||
return (ISC_TRUE);
|
||||
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
}
|
||||
|
||||
/*
|
||||
* Replacements for malloc() and free() -- they implicitly remember the
|
||||
* size of the object allocated (with some additional overhead).
|
||||
@@ -1343,22 +1201,6 @@ isc_mem_setdestroycheck(isc_mem_t *ctx, isc_boolean_t flag) {
|
||||
UNLOCK(&ctx->lock);
|
||||
}
|
||||
|
||||
void
|
||||
isc_mem_setsplit(isc_mem_t *ctx, isc_boolean_t flag) {
|
||||
#if ISC_MEM_USE_INTERNAL_MALLOC
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
LOCK(&ctx->lock);
|
||||
|
||||
ctx->trysplit = flag;
|
||||
|
||||
UNLOCK(&ctx->lock);
|
||||
#else /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
UNUSED(ctx);
|
||||
UNUSED(flag);
|
||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Quotas
|
||||
*/
|
||||
|
Reference in New Issue
Block a user