* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: mem.c,v 1.92 2001/06/05 22:14:18 tale Exp $ */
+/* $Id: mem.c,v 1.93 2001/06/11 20:27:16 gson Exp $ */
#include <config.h>
#if ISC_MEM_TRACKLINES
ISC_LIST(debuglink_t) debuglist;
#endif
+
+ unsigned int memalloc_failures;
};
#define MEMPOOL_MAGIC ISC_MAGIC('M', 'E', 'M', 'p')
table_size = ctx->basic_table_size + TABLE_INCREMENT;
table = (ctx->memalloc)(ctx->arg,
table_size * sizeof (unsigned char *));
- if (table == NULL)
+ if (table == NULL) {
+ ctx->memalloc_failures++;
return (ISC_FALSE);
+ }
if (ctx->basic_table_size != 0) {
memcpy(table, ctx->basic_table,
ctx->basic_table_size *
}
new = (ctx->memalloc)(ctx->arg, NUM_BASIC_BLOCKS * ctx->mem_target);
- if (new == NULL)
+ if (new == NULL) {
+ ctx->memalloc_failures++;
return (ISC_FALSE);
+ }
ctx->total += increment;
ctx->basic_table[ctx->basic_table_count] = new;
ctx->basic_table_count++;
goto done;
}
ret = (ctx->memalloc)(ctx->arg, size);
- if (ret != NULL) {
- ctx->total += size;
- ctx->inuse += size;
- ctx->stats[ctx->max_size].gets++;
- ctx->stats[ctx->max_size].totalgets++;
- /*
- * If we don't set new_size to size, then the
- * ISC_MEM_FILL code might write over bytes we
- * don't own.
- */
- new_size = size;
+ if (ret == NULL) {
+ ctx->memalloc_failures++;
+ goto done;
}
- goto done;
+ ctx->total += size;
+ ctx->inuse += size;
+ ctx->stats[ctx->max_size].gets++;
+ ctx->stats[ctx->max_size].totalgets++;
+ /*
+ * If we don't set new_size to size, then the
+ * ISC_MEM_FILL code might write over bytes we
+ * don't own.
+ */
+ new_size = size;
}
/*
#endif
ret = (ctx->memalloc)(ctx->arg, size);
+ if (ret == NULL)
+ ctx->memalloc_failures++;
#if ISC_MEM_FILL
if (ret != NULL)
ISC_LIST_INIT(ctx->debuglist);
#endif
+ ctx->memalloc_failures = 0;
+
*ctxp = ctx;
return (ISC_R_SUCCESS);