Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0978c9c256 |
@@ -127,7 +127,7 @@ add(char *key, int value) {
|
||||
isc_symvalue_t symvalue;
|
||||
|
||||
if (sym_mctx == NULL) {
|
||||
result = isc_mem_create(0, 0, &sym_mctx);
|
||||
result = isc_mem_create(&sym_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ main(int argc, char **argv) {
|
||||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != EOF) {
|
||||
switch (c) {
|
||||
|
||||
@@ -517,7 +517,7 @@ main(int argc, char **argv) {
|
||||
InitSockets();
|
||||
#endif
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
if (!quiet)
|
||||
RUNTIME_CHECK(setup_logging(mctx, errout, &lctx)
|
||||
== ISC_R_SUCCESS);
|
||||
|
||||
@@ -207,7 +207,7 @@ main(int argc, char **argv) {
|
||||
/* Use canonical algorithm name */
|
||||
algname = alg_totext(alg);
|
||||
|
||||
DO("create memory context", isc_mem_create(0, 0, &mctx));
|
||||
DO("create memory context", isc_mem_create(&mctx));
|
||||
|
||||
if (keyname == NULL) {
|
||||
const char *suffix = NULL;
|
||||
|
||||
@@ -209,7 +209,7 @@ main(int argc, char **argv) {
|
||||
keysize = alg_bits(alg);
|
||||
algname = alg_totext(alg);
|
||||
|
||||
DO("create memory context", isc_mem_create(0, 0, &mctx));
|
||||
DO("create memory context", isc_mem_create(&mctx));
|
||||
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
|
||||
|
||||
generate_key(mctx, alg, keysize, &key_txtbuffer);
|
||||
|
||||
+1
-1
@@ -1617,7 +1617,7 @@ main(int argc, char *argv[]) {
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("dns_lib_init failed: %d", result);
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("failed to create mctx");
|
||||
|
||||
|
||||
+1
-1
@@ -1347,7 +1347,7 @@ setup_libs(void) {
|
||||
if (!have_ipv6 && !have_ipv4)
|
||||
fatal("can't find either v4 or v6 networking");
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
check_result(result, "isc_mem_create");
|
||||
isc_mem_setname(mctx, "dig", NULL);
|
||||
|
||||
|
||||
@@ -1097,7 +1097,7 @@ main(int argc, char *argv[]) {
|
||||
int ch;
|
||||
char *endp;
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("out of memory");
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ main(int argc, char **argv) {
|
||||
usage();
|
||||
}
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("out of memory");
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ main(int argc, char **argv) {
|
||||
if (argc == 1)
|
||||
usage();
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("out of memory");
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ main(int argc, char **argv) {
|
||||
if (argc == 1)
|
||||
usage();
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
#if USE_PKCS11
|
||||
pk11_result_register();
|
||||
|
||||
@@ -260,7 +260,7 @@ main(int argc, char **argv) {
|
||||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
isc_stdtime_get(&now);
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ main(int argc, char **argv) {
|
||||
if (argc == 1)
|
||||
usage();
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("Out of memory");
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ main(int argc, char **argv) {
|
||||
if (argc == 1)
|
||||
usage();
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("Out of memory");
|
||||
|
||||
|
||||
@@ -3247,7 +3247,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
check_result(isc_app_start(), "isc_app_start");
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("out of memory");
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ main(int argc, char *argv[]) {
|
||||
isc_commandline_reset = true;
|
||||
check_result(isc_app_start(), "isc_app_start");
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("out of memory");
|
||||
|
||||
|
||||
+1
-2
@@ -436,7 +436,6 @@ static struct flag_def {
|
||||
{ "mctx", ISC_MEM_DEBUGCTX, false },
|
||||
{ NULL, 0, false }
|
||||
}, mem_context_flags[] = {
|
||||
{ "external", ISC_MEMFLAG_INTERNAL, true },
|
||||
{ "fill", ISC_MEMFLAG_FILL, false },
|
||||
{ "nofill", ISC_MEMFLAG_FILL, true },
|
||||
{ NULL, 0, false }
|
||||
@@ -1455,7 +1454,7 @@ main(int argc, char *argv[]) {
|
||||
named_g_chrootdir);
|
||||
}
|
||||
|
||||
result = isc_mem_create(0, 0, &named_g_mctx);
|
||||
result = isc_mem_create(&named_g_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
named_main_earlyfatal("isc_mem_create() failed: %s",
|
||||
isc_result_totext(result));
|
||||
|
||||
+2
-2
@@ -4366,9 +4366,9 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
|
||||
* cache, for the main cache memory and the heap
|
||||
* memory.
|
||||
*/
|
||||
CHECK(isc_mem_create(0, 0, &cmctx));
|
||||
CHECK(isc_mem_create(&cmctx));
|
||||
isc_mem_setname(cmctx, "cache", NULL);
|
||||
CHECK(isc_mem_create(0, 0, &hmctx));
|
||||
CHECK(isc_mem_create(&hmctx));
|
||||
isc_mem_setname(hmctx, "cache_heap", NULL);
|
||||
CHECK(dns_cache_create(cmctx, hmctx, named_g_taskmgr,
|
||||
named_g_timermgr, view->rdclass,
|
||||
|
||||
@@ -225,7 +225,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
|
||||
isc_mem_create(0, 0, &mctx);
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
cd = isc_mem_get(mctx, sizeof(*cd));
|
||||
if (cd == NULL) {
|
||||
|
||||
@@ -3293,7 +3293,7 @@ main(int argc, char **argv) {
|
||||
|
||||
pre_parse_args(argc, argv);
|
||||
|
||||
result = isc_mem_create(0, 0, &gmctx);
|
||||
result = isc_mem_create(&gmctx);
|
||||
check_result(result, "isc_mem_create");
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
@@ -65,7 +65,7 @@ main(int argc, char *argv[]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isc_mem_create(0, 0, &mctx) != ISC_R_SUCCESS) {
|
||||
if (isc_mem_create(&mctx) != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "isc_mem_create() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+1
-1
@@ -930,7 +930,7 @@ main(int argc, char **argv) {
|
||||
|
||||
serial = isc_random32();
|
||||
|
||||
DO("create memory context", isc_mem_create(0, 0, &rndc_mctx));
|
||||
DO("create memory context", isc_mem_create(&rndc_mctx));
|
||||
DO("create socket manager", isc_socketmgr_create(rndc_mctx, &socketmgr));
|
||||
DO("create task manager", isc_taskmgr_create(rndc_mctx, 1, 0, &taskmgr));
|
||||
DO("create task", isc_task_create(taskmgr, 0, &task));
|
||||
|
||||
@@ -68,7 +68,7 @@ main(int argc, char **argv) {
|
||||
char *filename = NULL;
|
||||
unsigned int zonetype = 0;
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
result = isc_log_create(mctx, &lctx, &lcfg);
|
||||
check_result(result, "isc_log_create()");
|
||||
|
||||
@@ -96,7 +96,7 @@ main(int argc, char **argv) {
|
||||
journal = argv[4];
|
||||
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_mem_create(&mctx));
|
||||
|
||||
CHECK(dst_lib_init(mctx, NULL));
|
||||
dst_active = true;
|
||||
@@ -152,4 +152,3 @@ main(int argc, char **argv) {
|
||||
|
||||
return(result != ISC_R_SUCCESS ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ main(int argc, char **argv) {
|
||||
/*
|
||||
* EVERYTHING needs a memory context.
|
||||
*/
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
cmp = NULL;
|
||||
RUNTIME_CHECK(isc_mempool_create(mctx, sizeof(client_t), &cmp)
|
||||
|
||||
@@ -87,7 +87,7 @@ main(int argc, char *argv[]) {
|
||||
dns_result_register();
|
||||
|
||||
mctx = NULL;
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, "nvw:")) != -1) {
|
||||
switch (ch) {
|
||||
|
||||
@@ -201,7 +201,7 @@ main(int argc, char *argv[]) {
|
||||
dns_result_register();
|
||||
|
||||
mctx = NULL;
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, "d:vw:")) != -1) {
|
||||
switch (ch) {
|
||||
|
||||
@@ -364,7 +364,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
dns_result_register();
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(dns_dbtable_create(mctx, dns_rdataclass_in, &dbtable) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ main(int argc, char *argv[]) {
|
||||
dns_result_register();
|
||||
|
||||
mctx = NULL;
|
||||
RUNCHECK(isc_mem_create(0, 0, &mctx));
|
||||
RUNCHECK(isc_mem_create(&mctx));
|
||||
|
||||
RUNCHECK(isc_log_create(mctx, &lctx, &lcfg));
|
||||
isc_log_setcontext(lctx);
|
||||
|
||||
@@ -30,7 +30,7 @@ main(int argc, char **argv) {
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
result = isc_interfaceiter_create(mctx, &iter);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
|
||||
@@ -90,7 +90,7 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
|
||||
|
||||
if (masterfile) {
|
||||
|
||||
@@ -106,7 +106,7 @@ main(int argc, char **argv) {
|
||||
lctx = NULL;
|
||||
lcfg = NULL;
|
||||
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_mem_create(&mctx));
|
||||
CHECK(isc_log_create(mctx, &lctx, &lcfg));
|
||||
|
||||
CHECK(isc_log_settag(lcfg, progname));
|
||||
|
||||
@@ -57,7 +57,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
UNUSED(argc);
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
if (argv[1]) {
|
||||
isc_buffer_init(&source, argv[1], strlen(argv[1]));
|
||||
|
||||
@@ -31,7 +31,7 @@ main(int argc, char *argv[]) {
|
||||
isc_mutex_init(&lock);
|
||||
|
||||
mctx = NULL;
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
mp1 = NULL;
|
||||
RUNTIME_CHECK(isc_mempool_create(mctx, 24, &mp1) == ISC_R_SUCCESS);
|
||||
|
||||
@@ -190,7 +190,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
dns_result_register();
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
check_result(result, "isc_mem_create()");
|
||||
|
||||
argc--;
|
||||
|
||||
@@ -101,7 +101,7 @@ main(int argc, char *argv[]) {
|
||||
isc_app_start();
|
||||
isc_interval_set(&linterval, 1, 0);
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, 3, 0, &taskmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) ==
|
||||
|
||||
@@ -281,7 +281,7 @@ main(int argc, char **argv) {
|
||||
*/
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
printf("isc_mem_create: %s: exiting\n",
|
||||
dns_result_totext(result));
|
||||
|
||||
@@ -178,9 +178,9 @@ main(int argc, char *argv[]) {
|
||||
printf("%u workers\n", workers);
|
||||
|
||||
mctx = NULL;
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
mctx2 = NULL;
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx2) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx2) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &task_manager) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timer_manager) ==
|
||||
|
||||
@@ -207,7 +207,7 @@ main(int argc, char *argv[]) {
|
||||
isc_mutex_init(&lock);
|
||||
|
||||
mctx = NULL;
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, "vp:")) != -1) {
|
||||
switch (ch) {
|
||||
|
||||
@@ -289,7 +289,7 @@ main(int argc, char *argv[]) {
|
||||
* EVERYTHING needs a memory context.
|
||||
*/
|
||||
mctx = NULL;
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
* The task manager is independent (other than memory context)
|
||||
|
||||
@@ -59,7 +59,7 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_symtab_create(mctx, 691, undefine_action, NULL,
|
||||
case_sensitive, &st) == ISC_R_SUCCESS);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ main(int argc, char *argv[]) {
|
||||
workers = 2;
|
||||
printf("%u workers\n", workers);
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, workers, 0, &manager) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
@@ -107,7 +107,7 @@ main(int argc, char *argv[]) {
|
||||
workers = 2;
|
||||
printf("%u workers\n", workers);
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx1) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx1) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx1, workers, 0, &manager) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx1, &timgr) == ISC_R_SUCCESS);
|
||||
|
||||
@@ -281,7 +281,7 @@ main(int argc, char **argv) {
|
||||
usage();
|
||||
|
||||
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, 2, 0, &taskmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
|
||||
|
||||
@@ -268,7 +268,7 @@ main(int argc, char *argv[]) {
|
||||
isc_sockaddr_fromin(&dstaddr, &inaddr, port);
|
||||
|
||||
mctx = NULL;
|
||||
RUNCHECK(isc_mem_create(0, 0, &mctx));
|
||||
RUNCHECK(isc_mem_create(&mctx));
|
||||
|
||||
lctx = NULL;
|
||||
lcfg = NULL;
|
||||
@@ -337,4 +337,3 @@ main(int argc, char *argv[]) {
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ main(int argc, char **argv) {
|
||||
|
||||
dns_result_register();
|
||||
|
||||
CHECK(isc_mem_create(0, 0, &mctx), "isc_mem_create()");
|
||||
CHECK(isc_mem_create(&mctx), "isc_mem_create()");
|
||||
CHECK(dst_lib_init(mctx, NULL), "dst_lib_init()");
|
||||
CHECK(isc_log_create(mctx, &log_, &logconfig), "isc_log_create()");
|
||||
isc_log_setcontext(log_);
|
||||
|
||||
@@ -227,7 +227,7 @@ main(int argc, char *argv[]) {
|
||||
|
||||
mctx = NULL;
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
RUNCHECK(isc_mem_create(0, 0, &mctx));
|
||||
RUNCHECK(isc_mem_create(&mctx));
|
||||
|
||||
log = NULL;
|
||||
logconfig = NULL;
|
||||
|
||||
@@ -166,7 +166,7 @@ main(int argc, char **argv) {
|
||||
dns_result_register();
|
||||
|
||||
mctx = NULL;
|
||||
RUNCHECK(isc_mem_create(0, 0, &mctx));
|
||||
RUNCHECK(isc_mem_create(&mctx));
|
||||
|
||||
log = NULL;
|
||||
logconfig = NULL;
|
||||
|
||||
@@ -136,7 +136,7 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
|
||||
@@ -341,7 +341,7 @@ main(int argc, char *argv[]) {
|
||||
if (argc < 1)
|
||||
fatal("no file specified");
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
|
||||
dns_result_register();
|
||||
|
||||
|
||||
+1
-1
@@ -1947,7 +1947,7 @@ main(int argc, char *argv[]) {
|
||||
preparse_args(argc, argv);
|
||||
|
||||
mctx = NULL;
|
||||
RUNCHECK(isc_mem_create(0, 0, &mctx));
|
||||
RUNCHECK(isc_mem_create(&mctx));
|
||||
|
||||
lctx = NULL;
|
||||
lcfg = NULL;
|
||||
|
||||
@@ -67,7 +67,7 @@ main(int argc, char **argv) {
|
||||
|
||||
file = argv[1];
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(setup_logging(mctx, stderr, &lctx) == ISC_R_SUCCESS);
|
||||
|
||||
result = dns_journal_print(mctx, file, stdout);
|
||||
|
||||
@@ -146,7 +146,7 @@ main(int argc, char *argv[]) {
|
||||
if (doexit)
|
||||
exit(0);
|
||||
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
|
||||
@@ -60,7 +60,7 @@ int ctx_init(void) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (isc_mem_create(0, 0, &ctx.mem) != ISC_R_SUCCESS)
|
||||
if (isc_mem_create(&ctx.mem) != ISC_R_SUCCESS)
|
||||
goto done;
|
||||
|
||||
if (isc_log_create(ctx.mem, &ctx.log, &ctx.logcfg) != ISC_R_SUCCESS)
|
||||
@@ -337,6 +337,3 @@ struct DNSConf {
|
||||
%readonly
|
||||
dns_c_ctx_t *confctx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
|
||||
*
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the
|
||||
* above copyright notice and this permission notice appear in all
|
||||
* copies.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND STICHTING NLNET
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
@@ -14,15 +14,15 @@
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
* USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*
|
||||
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
|
||||
* conceived and contributed by Rob Butler.
|
||||
*
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the
|
||||
* above copyright notice and this permission notice appear in all
|
||||
* copies.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
@@ -112,9 +112,9 @@ operation_bulk(void);
|
||||
void
|
||||
operation_listOrDelete(bool dlt);
|
||||
|
||||
|
||||
|
||||
/*%
|
||||
* Maximum length of a single data line that
|
||||
* Maximum length of a single data line that
|
||||
* may be inserted into database by this program.
|
||||
* If you need to insert a line of data that is more
|
||||
* than 10,000 characters change this definition.
|
||||
@@ -124,7 +124,7 @@ operation_listOrDelete(bool dlt);
|
||||
|
||||
/*%
|
||||
* BDB database names. If you want to use different
|
||||
* database names change them here.
|
||||
* database names change them here.
|
||||
*/
|
||||
|
||||
#define dlz_data "dns_data"
|
||||
@@ -217,7 +217,7 @@ bool create_allowed = false;
|
||||
char *key = NULL; /*%< key to use in list & del operations */
|
||||
|
||||
/*% dump DB in DLZBDB bulk format */
|
||||
bool list_everything = false;
|
||||
bool list_everything = false;
|
||||
unsigned int key_val; /*%< key as unsigned int used in list & del operations */
|
||||
char *zone = NULL; /*%< zone to use in list operations */
|
||||
char *host = NULL; /*%< host to use in list operations */
|
||||
@@ -232,7 +232,7 @@ isc_lex_t *lexer = NULL; /*%< lexer for use to use in parsing input */
|
||||
isc_mem_t *lex_mctx = NULL; /*%< memory context for lexer */
|
||||
char lex_data_buf[max_data_len]; /*%< data array to use for lex_buffer below */
|
||||
isc_buffer_t lex_buffer; /*%< buffer for lexer during add operation */
|
||||
|
||||
|
||||
|
||||
/*%
|
||||
* Displays usage message
|
||||
@@ -325,7 +325,7 @@ gethost(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey) {
|
||||
if ((token = strtok_r(NULL, " ", &last)) == NULL) {
|
||||
return BDBparseErr;
|
||||
}
|
||||
|
||||
|
||||
/* copy string for "host" secondary index */
|
||||
if ((skey->data = strdup(token)) == NULL) {
|
||||
return BDBparseErr;
|
||||
@@ -494,8 +494,8 @@ insert_data(void) {
|
||||
isc_buffer_init(&buf2, &data_arr2, max_data_len);
|
||||
|
||||
while (loop) {
|
||||
result = isc_lex_gettoken(lexer, opt, &token);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
result = isc_lex_gettoken(lexer, opt, &token);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto data_cleanup;
|
||||
|
||||
switch(token.type) {
|
||||
@@ -533,7 +533,7 @@ insert_data(void) {
|
||||
break;
|
||||
case isc_tokentype_eol:
|
||||
case isc_tokentype_eof:
|
||||
|
||||
|
||||
if ((data_type != 'u' && isc_buffer_usedlength(&buf) > 0) || data_type == 'b') {
|
||||
/* perform insert operation */
|
||||
if (data_type == 'd' || data_type == 'D') {
|
||||
@@ -541,7 +541,7 @@ insert_data(void) {
|
||||
isc_buffer_putmem(&buf, "\0", 1);
|
||||
put_data(true, NULL, (char *) &data_arr);
|
||||
} else if (data_type == 'c' || data_type == 'C') {
|
||||
put_data(false, (char *) &data_arr,
|
||||
put_data(false, (char *) &data_arr,
|
||||
(char *) &data_arr2);
|
||||
} else if (data_type == 'b') {
|
||||
fprintf(stderr, "Bad / unknown token encountered on line %lu."\
|
||||
@@ -554,7 +554,7 @@ insert_data(void) {
|
||||
|
||||
if (token.type == isc_tokentype_eof) {
|
||||
loop = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset buffer for next insert */
|
||||
isc_buffer_clear(&buf);
|
||||
@@ -573,7 +573,7 @@ insert_data(void) {
|
||||
data_cleanup:
|
||||
/* let user know we had problems */
|
||||
fprintf(stderr, "Unknown error processing tokens during \"add\" or " \
|
||||
"\"bulk\" operation.\nStoped processing on line %lu.",
|
||||
"\"bulk\" operation.\nStoped processing on line %lu.",
|
||||
isc_lex_getsourceline(lexer));
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ openBDB(void) {
|
||||
/* Basically BDB allocates and assigns memory to db->dbenv */
|
||||
bdbres = db_env_create(&db.dbenv, 0);
|
||||
if (bdbres != 0) {
|
||||
fprintf(stderr, "BDB environment could not be created. BDB error: %s",
|
||||
fprintf(stderr, "BDB environment could not be created. BDB error: %s",
|
||||
db_strerror(bdbres));
|
||||
result = ISC_R_FAILURE;
|
||||
goto openBDB_cleanup;
|
||||
@@ -597,10 +597,10 @@ openBDB(void) {
|
||||
/* open BDB environment */
|
||||
if (create_allowed == true) {
|
||||
/* allowed to create new files */
|
||||
bdbres = db.dbenv->open(db.dbenv, db_envdir,
|
||||
bdbres = db.dbenv->open(db.dbenv, db_envdir,
|
||||
DB_INIT_CDB | DB_INIT_MPOOL | DB_CREATE, 0);
|
||||
} else { /* not allowed to create new files. */
|
||||
bdbres = db.dbenv->open(db.dbenv, db_envdir,
|
||||
bdbres = db.dbenv->open(db.dbenv, db_envdir,
|
||||
DB_INIT_CDB | DB_INIT_MPOOL, 0);
|
||||
}
|
||||
if (bdbres != 0) {
|
||||
@@ -615,7 +615,7 @@ openBDB(void) {
|
||||
result = bdb_opendb(DB_RECNO, &db.data, dlz_data, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto openBDB_cleanup;
|
||||
|
||||
|
||||
/* open dlz_host database */
|
||||
result = bdb_opendb(DB_BTREE, &db.host, dlz_host, DB_DUP | DB_DUPSORT);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -668,7 +668,7 @@ open_lexer(void) {
|
||||
return ISC_R_SUCCESS;
|
||||
|
||||
/* allocate memory for lexer, and verify it was allocated */
|
||||
result = isc_mem_create(0, 0, &lex_mctx);
|
||||
result = isc_mem_create(&lex_mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "unexpected error creating lexer\n");
|
||||
return result;
|
||||
@@ -693,7 +693,7 @@ open_lexer(void) {
|
||||
|
||||
void
|
||||
close_lexer(void) {
|
||||
|
||||
|
||||
/* If lexer is still open, close it & destroy it. */
|
||||
if (lexer != NULL) {
|
||||
isc_lex_close(lexer);
|
||||
@@ -722,10 +722,10 @@ operation_add(void) {
|
||||
if (open_lexer() != ISC_R_SUCCESS) {
|
||||
quit(4);
|
||||
}
|
||||
|
||||
|
||||
/* copy input data to buffer */
|
||||
isc_buffer_putstr(&lex_buffer, a_data);
|
||||
|
||||
|
||||
/* tell lexer to use buffer as input */
|
||||
if (isc_lex_openbuffer(lexer, &lex_buffer) != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "unexpected error opening lexer buffer");
|
||||
@@ -757,7 +757,7 @@ operation_bulk(void) {
|
||||
if (bulk_file == NULL) {
|
||||
if (isc_lex_openstream(lexer, stdin) != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "unexpected error opening stdin by lexer.");
|
||||
quit(4);
|
||||
quit(4);
|
||||
}
|
||||
} else if (isc_lex_openfile(lexer, bulk_file) != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "unexpected error opening %s by lexer.", bulk_file);
|
||||
@@ -765,7 +765,7 @@ operation_bulk(void) {
|
||||
}
|
||||
|
||||
/* common logic for "add" & "bulk" operations are handled by insert_data */
|
||||
insert_data();
|
||||
insert_data();
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -779,7 +779,7 @@ bulk_write(char type, DB *database, DBC *dbcursor, DBT *bdbkey, DBT *bdbdata) {
|
||||
|
||||
/* use a 5MB buffer for the bulk dump */
|
||||
int buffer_size = 5 * 1024 * 1024;
|
||||
|
||||
|
||||
/* try to allocate a 5 MB buffer, if we fail write err msg, die. */
|
||||
bdbdata->data = malloc(buffer_size);
|
||||
if (bdbdata->data == NULL) {
|
||||
@@ -802,7 +802,7 @@ bulk_write(char type, DB *database, DBC *dbcursor, DBT *bdbkey, DBT *bdbdata) {
|
||||
for (;;) {
|
||||
|
||||
/* loop through data until DB_NOTFOUND is returned */
|
||||
bdbres = dbcursor->c_get(dbcursor, bdbkey, bdbdata,
|
||||
bdbres = dbcursor->c_get(dbcursor, bdbkey, bdbdata,
|
||||
DB_MULTIPLE_KEY | DB_NEXT);
|
||||
/* if not successful did we encounter DB_NOTFOUND, or */
|
||||
/* have a different problem. */
|
||||
@@ -828,7 +828,7 @@ bulk_write(char type, DB *database, DBC *dbcursor, DBT *bdbkey, DBT *bdbdata) {
|
||||
if (type == 'c')
|
||||
printf("c %.*s %.*s\n",(int)retklen, retkey,(int)retdlen, retdata);
|
||||
else
|
||||
printf("d %.*s\n", (int)retdlen, retdata);
|
||||
printf("d %.*s\n", (int)retdlen, retdata);
|
||||
} /* end of for (DB_MULTIPLE_INIT....) */
|
||||
|
||||
} /* end of for (;;) */
|
||||
@@ -995,7 +995,7 @@ operation_listOrDelete(bool dlt) {
|
||||
/* print a header to explain the output */
|
||||
printf("KEY | DATA\n");
|
||||
/* loop and list all results. */
|
||||
while (bdbres == 0) {
|
||||
while (bdbres == 0) {
|
||||
/* get data */
|
||||
bdbres = db.cursor4->c_get(db.cursor4, &bdbkey, &bdbdata, 0);
|
||||
/* verify call had no errors */
|
||||
@@ -1008,7 +1008,7 @@ operation_listOrDelete(bool dlt) {
|
||||
}
|
||||
|
||||
if (c_ip != NULL && c_zone == NULL) {
|
||||
fprintf(stderr, "i may only be specified when c is also specified\n");
|
||||
fprintf(stderr, "i may only be specified when c is also specified\n");
|
||||
quit(2);
|
||||
}
|
||||
/* if client_zone was passed */
|
||||
@@ -1060,7 +1060,7 @@ operation_listOrDelete(bool dlt) {
|
||||
if (c_ip != NULL) {
|
||||
break;
|
||||
}
|
||||
bdbres = db.cursor->c_get(db.cursor, &bdbkey, &bdbdata, DB_NEXT_DUP);
|
||||
bdbres = db.cursor->c_get(db.cursor, &bdbkey, &bdbdata, DB_NEXT_DUP);
|
||||
if (bdbres != 0) {
|
||||
break;
|
||||
}
|
||||
@@ -1109,7 +1109,7 @@ main(int argc, char **argv) {
|
||||
case 'a':
|
||||
checkOp(operation);
|
||||
operation = add;
|
||||
a_data = isc_commandline_argument;
|
||||
a_data = isc_commandline_argument;
|
||||
break;
|
||||
case 'f':
|
||||
checkOp(operation);
|
||||
@@ -1211,4 +1211,3 @@ main(int argc, char **argv) {
|
||||
quit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -282,7 +282,7 @@ rudimentary initialization of both.
|
||||
isc_log_t *lctx;
|
||||
isc_logconfig_t *lcfg;
|
||||
|
||||
if (isc_mem_create(0, 0, &mctx) != ISC_R_SUCCESS) ||
|
||||
if (isc_mem_create(&mctx) != ISC_R_SUCCESS) ||
|
||||
isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS))
|
||||
oops_it_didnt_work();
|
||||
|
||||
|
||||
+12
-12
@@ -404,7 +404,7 @@ for the ISC library are in `lib/isc/include/isc/result.h`.
|
||||
|
||||
ISC library result codes (many of which are generically useful elsewhere)
|
||||
begin with `ISC_R`: examples inclue `ISC_R_SUCCESS`, `ISC_R_FAILURE`,
|
||||
`ISC_R_NOMEMORY`, etc.
|
||||
`ISC_R_NOMEMORY`, etc.
|
||||
|
||||
DNS library result codes begin with `DNS_R`: `DNS_R_SERVFAIL`, `DNS_R_NXRRSET`,
|
||||
etc). Other sets of result codes are defined for crypto functions (`DST_R`
|
||||
@@ -430,7 +430,7 @@ into 'consumed' and 'remaining'.
|
||||
|
||||
When parsing a message, the message to be parsed in in the 'used'
|
||||
part of the buffer. As the message is parsed, the 'consumed'
|
||||
subregion grows and the 'remaining' subregion shrinks.
|
||||
subregion grows and the 'remaining' subregion shrinks.
|
||||
|
||||
When creating a message, data is written into the 'available'
|
||||
subregion, which then becomes part of 'used'.
|
||||
@@ -504,7 +504,7 @@ memory has not been freed when BIND shuts down.
|
||||
To create a basic memory context, use:
|
||||
|
||||
isc_mem_t *mctx = NULL;
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
|
||||
(The zeroes are tuning parameters, `max_size` and `target_size`: Any
|
||||
allocations smaller than `max_size` will be satisfied by getting
|
||||
@@ -538,7 +538,7 @@ memory context is freed before all references have been cleaned up.
|
||||
/* Populate other isc_foo members here */
|
||||
|
||||
foo->magic = ISC_FOO_MAGIC;
|
||||
|
||||
|
||||
*foop = foo;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -645,7 +645,7 @@ More macros are provided for iterating the list:
|
||||
|
||||
isc_foo_t *foo;
|
||||
for (foo = ISC_LIST_HEAD(foolist);
|
||||
foo != NULL;
|
||||
foo != NULL;
|
||||
foo = ISC_LIST_NEXT(foo, link))
|
||||
{
|
||||
/* do things */
|
||||
@@ -795,7 +795,7 @@ The return value may be:
|
||||
* `dns_name_commonancestor`: name1 and name2 share some labels
|
||||
* `dns_name_equal`: name1 and name2 are the same
|
||||
|
||||
Some simpler comparison functions are provided for convenience when
|
||||
Some simpler comparison functions are provided for convenience when
|
||||
not all of this information is required:
|
||||
|
||||
* `dns_name_compare()`: returns the sort order of two names but
|
||||
@@ -866,7 +866,7 @@ sets have been defined:
|
||||
|
||||
Each of these has a `first()`, `next()` and `current()` function; for
|
||||
example, `dns_rdataset_first()`, `dns_rdataset_next()`, and
|
||||
`dns_rdataset_current()`.
|
||||
`dns_rdataset_current()`.
|
||||
|
||||
The `first()` and `next()` functions move the iterator's cursor and so that
|
||||
the data at a new location can be retrieved. (Most of these can only step
|
||||
@@ -1015,7 +1015,7 @@ messages up to the current debugging level are written to the channel.
|
||||
|
||||
These objects -- the category, module, and channel -- direct hessages
|
||||
to desired destinations. Each category/module pair can be associated
|
||||
with a specific channel, and the correct destination will be used
|
||||
with a specific channel, and the correct destination will be used
|
||||
when a message is logged by `isc_log_write()`.
|
||||
|
||||
In `isc_log_write()`, the logging system first looks up a list that
|
||||
@@ -1073,7 +1073,7 @@ the following steps need to be taken to initialize it.
|
||||
isc_log_t *lctx;
|
||||
isc_logconfig_t *lcfg;
|
||||
|
||||
if (isc_mem_create(0, 0, &mctx) != ISC_R_SUCCESS) ||
|
||||
if (isc_mem_create(&mctx) != ISC_R_SUCCESS) ||
|
||||
isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS))
|
||||
oops_it_didnt_work();
|
||||
|
||||
@@ -1157,7 +1157,7 @@ to control the closing of log files.
|
||||
|
||||
void isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level);
|
||||
unsigned int isc_log_getdebuglevel(isc_log_t *lctx);
|
||||
|
||||
|
||||
These set and retrieve the current debugging level of the program.
|
||||
`isc_log_getdebuglevel()` can be used so that you need not keep track of
|
||||
the level yourself in another variable.
|
||||
@@ -1428,7 +1428,7 @@ be triggered at that time.
|
||||
result = isc_timer_create(timermgr, isc_timertype_once, NULL,
|
||||
interval, task, timeout, arg, &timer);
|
||||
|
||||
An event can also be explicitly triggered via `isc_task_send()`.
|
||||
An event can also be explicitly triggered via `isc_task_send()`.
|
||||
|
||||
static void
|
||||
do_things(isc_task_t *task, isc_event_t *event) {
|
||||
@@ -1438,7 +1438,7 @@ An event can also be explicitly triggered via `isc_task_send()`.
|
||||
...
|
||||
|
||||
/*
|
||||
* Allocate an event that calls 'do_things' with a
|
||||
* Allocate an event that calls 'do_things' with a
|
||||
* NULL argument, using 'myself' as ev_sender.
|
||||
*
|
||||
* DNS_EVENT_DOTHINGS must be defined in <dns/events.h>.
|
||||
|
||||
@@ -98,7 +98,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
rdtype = typelist[(*data++) % types]; size--;
|
||||
rdclass = classlist[(*data++) % classes]; size--;
|
||||
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_mem_create(&mctx));
|
||||
|
||||
CHECK(isc_lex_create(mctx, 64, &lex));
|
||||
memset(specials, 0, sizeof(specials));
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
static void __attribute__((constructor)) init(void) {
|
||||
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_mem_create(&mctx) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(dst_lib_init(mctx, NULL) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -411,7 +411,7 @@ dns_client_create(dns_client_t **clientp, unsigned int options) {
|
||||
unsigned int logdebuglevel = 0;
|
||||
#endif
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
result = isc_appctx_create(mctx, &actx);
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ dt_init(void) {
|
||||
int ret;
|
||||
|
||||
if (dt_mctx == NULL)
|
||||
result = isc_mem_create(0, 0, &dt_mctx);
|
||||
result = isc_mem_create(&dt_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto unlock;
|
||||
isc_mem_setname(dt_mctx, "dt", NULL);
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ state_key_init(void) {
|
||||
int ret;
|
||||
|
||||
if (state_mctx == NULL)
|
||||
result = isc_mem_create(0, 0, &state_mctx);
|
||||
result = isc_mem_create(&state_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto unlock;
|
||||
isc_mem_setname(state_mctx, "geoip_state", NULL);
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ initialize(void) {
|
||||
|
||||
REQUIRE(initialize_done == false);
|
||||
|
||||
result = isc_mem_create(0, 0, &dns_g_mctx);
|
||||
result = isc_mem_create(&dns_g_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return;
|
||||
dns_result_register();
|
||||
|
||||
+1
-1
@@ -1299,7 +1299,7 @@ totext_filter_proc_key_init(void) {
|
||||
if (!thread_key_initialized) {
|
||||
LOCK(&thread_key_mutex);
|
||||
if (thread_key_mctx == NULL)
|
||||
result = isc_mem_create(0, 0, &thread_key_mctx);
|
||||
result = isc_mem_create(&thread_key_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto unlock;
|
||||
isc_mem_setname(thread_key_mctx, "threadkey", NULL);
|
||||
|
||||
+1
-1
@@ -9998,7 +9998,7 @@ dns_resolver_create(dns_view_t *view,
|
||||
* contention among multiple threads. Do this only when
|
||||
* enabling threads because it will be require more memory.
|
||||
*/
|
||||
result = isc_mem_create(0, 0, &res->buckets[i].mctx);
|
||||
result = isc_mem_create(&res->buckets[i].mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_task_detach(&res->buckets[i].task);
|
||||
isc_mutex_destroy(&res->buckets[i].lock);
|
||||
|
||||
@@ -68,7 +68,7 @@ getoriginnode_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_create(0, 0, &mymctx);
|
||||
result = isc_mem_create(&mymctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_db_create(mymctx, "rbt", dns_rootname, dns_dbtype_zone,
|
||||
@@ -97,7 +97,7 @@ getsetservestalettl_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_create(0, 0, &mymctx);
|
||||
result = isc_mem_create(&mymctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_db_create(mymctx, "rbt", dns_rootname, dns_dbtype_cache,
|
||||
@@ -141,7 +141,7 @@ dns_dbfind_staleok_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_create(0, 0, &mymctx);
|
||||
result = isc_mem_create(&mymctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_db_create(mymctx, "rbt", dns_rootname, dns_dbtype_cache,
|
||||
|
||||
@@ -133,7 +133,7 @@ dns_test_begin(FILE *logfile, bool start_managers) {
|
||||
}
|
||||
|
||||
INSIST(mctx == NULL);
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_mem_create(&mctx));
|
||||
|
||||
/* Don't check the memory leaks as they hide the assertions */
|
||||
isc_mem_setdestroycheck(mctx, false);
|
||||
|
||||
+1
-1
@@ -832,7 +832,7 @@ dns_view_createresolver(dns_view_t *view,
|
||||
dns_resolver_whenshutdown(view->resolver, view->task, &event);
|
||||
view->attributes &= ~DNS_VIEWATTR_RESSHUTDOWN;
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_resolver_shutdown(view->resolver);
|
||||
return (result);
|
||||
|
||||
+1
-1
@@ -16778,7 +16778,7 @@ mctxinit(void **target, void *arg) {
|
||||
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_mem_setname(mctx, "zonemgr-pool", NULL);
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp,
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_mem_create(0, 0, mctxp);
|
||||
result = isc_mem_create(mctxp);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ static void
|
||||
setup_test() {
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
|
||||
@@ -41,21 +41,6 @@ typedef void (*isc_memfree_t)(void *, void *);
|
||||
#define ISC_MEM_TRACKLINES 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Define ISC_MEM_CHECKOVERRUN=1 to turn on checks for using memory outside
|
||||
* the requested space. This will increase the size of each allocation.
|
||||
*
|
||||
* If we are performing a Coverity static analysis then ISC_MEM_CHECKOVERRUN
|
||||
* can hide bugs that would otherwise discovered so force to zero.
|
||||
*/
|
||||
#ifdef __COVERITY__
|
||||
#undef ISC_MEM_CHECKOVERRUN
|
||||
#define ISC_MEM_CHECKOVERRUN 0
|
||||
#endif
|
||||
#ifndef ISC_MEM_CHECKOVERRUN
|
||||
#define ISC_MEM_CHECKOVERRUN 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Define ISC_MEMPOOL_NAMES=1 to make memory pools store a symbolic
|
||||
* name so that the leaking pool can be more readily identified in
|
||||
@@ -111,30 +96,17 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
|
||||
#define _ISC_MEM_FLARG
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Define ISC_MEM_USE_INTERNAL_MALLOC=1 to use the internal malloc()
|
||||
* implementation in preference to the system one. The internal malloc()
|
||||
* is very space-efficient, and quite fast on uniprocessor systems. It
|
||||
* performs poorly on multiprocessor machines.
|
||||
* JT: we can overcome the performance issue on multiprocessor machines
|
||||
* by carefully separating memory contexts.
|
||||
*/
|
||||
|
||||
#ifndef ISC_MEM_USE_INTERNAL_MALLOC
|
||||
#define ISC_MEM_USE_INTERNAL_MALLOC 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Flags for isc_mem_createx() calls.
|
||||
*/
|
||||
#define ISC_MEMFLAG_NOLOCK 0x00000001 /* no lock is necessary */
|
||||
#define ISC_MEMFLAG_INTERNAL 0x00000002 /* use internal malloc */
|
||||
#define ISC_MEMFLAG_FILL 0x00000004 /* fill with pattern after alloc and frees */
|
||||
#define ISC_MEMFLAG_NOOP_1 0x00000001 /* obsolete, noop */
|
||||
#define ISC_MEMFLAG_NOOP_2 0x00000002 /* obsolete, noop */ */
|
||||
#define ISC_MEMFLAG_FILL 0x00000004 /* fill with pattern after alloc and frees */
|
||||
|
||||
#if !ISC_MEM_USE_INTERNAL_MALLOC
|
||||
#define ISC_MEMFLAG_DEFAULT 0
|
||||
#ifndef NDEBUG
|
||||
#define ISC_MEMFLAG_DEFAULT ISC_MEMFLAG_FILL
|
||||
#else
|
||||
#define ISC_MEMFLAG_DEFAULT ISC_MEMFLAG_INTERNAL|ISC_MEMFLAG_FILL
|
||||
#define ISC_MEMFLAG_DEFAULT 0
|
||||
#endif
|
||||
|
||||
/*%
|
||||
@@ -255,41 +227,21 @@ struct isc_mempool {
|
||||
|
||||
/*@{*/
|
||||
isc_result_t
|
||||
isc_mem_create(size_t max_size, size_t target_size,
|
||||
isc_mem_t **mctxp);
|
||||
isc_mem_create(isc_mem_t **mctxp);
|
||||
|
||||
isc_result_t
|
||||
isc_mem_createx(size_t max_size, size_t target_size,
|
||||
isc_memalloc_t memalloc, isc_memfree_t memfree,
|
||||
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.
|
||||
*
|
||||
* 'max_size' and 'target_size' are tuning parameters. When
|
||||
* ISC_MEMFLAG_INTERNAL is set, allocations smaller than 'max_size'
|
||||
* will be satisfied by getting blocks of size 'target_size' from the
|
||||
* system allocator and breaking them up into pieces; larger allocations
|
||||
* will use the system allocator directly. If 'max_size' and/or
|
||||
* 'target_size' are zero, default values will be * used. When
|
||||
* ISC_MEMFLAG_INTERNAL is not set, 'target_size' is ignored.
|
||||
*
|
||||
* 'max_size' is also used to size the statistics arrays and the array
|
||||
* used to record active memory when ISC_MEM_DEBUGRECORD is set. Setting
|
||||
* 'max_size' too low can have detrimental effects on performance.
|
||||
*
|
||||
* 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:
|
||||
* mctxp != NULL && *mctxp == NULL */
|
||||
/*@}*/
|
||||
|
||||
+53
-533
@@ -35,8 +35,8 @@
|
||||
|
||||
#include "mem_p.h"
|
||||
|
||||
#define MCTXLOCK(m, l) if (((m)->flags & ISC_MEMFLAG_NOLOCK) == 0) LOCK(l)
|
||||
#define MCTXUNLOCK(m, l) if (((m)->flags & ISC_MEMFLAG_NOLOCK) == 0) UNLOCK(l)
|
||||
#define MCTXLOCK(m, l) LOCK(l)
|
||||
#define MCTXUNLOCK(m, l) UNLOCK(l)
|
||||
|
||||
#ifndef ISC_MEM_DEBUGGING
|
||||
#define ISC_MEM_DEBUGGING 0
|
||||
@@ -48,11 +48,7 @@ LIBISC_EXTERNAL_DATA unsigned int isc_mem_defaultflags = ISC_MEMFLAG_DEFAULT;
|
||||
* Constants.
|
||||
*/
|
||||
|
||||
#define DEF_MAX_SIZE 1100
|
||||
#define DEF_MEM_TARGET 4096
|
||||
#define ALIGNMENT_SIZE 8U /*%< must be a power of 2 */
|
||||
#define NUM_BASIC_BLOCKS 64 /*%< must be > 1 */
|
||||
#define TABLE_INCREMENT 1024
|
||||
#define DEBUG_TABLE_COUNT 512U
|
||||
|
||||
/*
|
||||
@@ -99,8 +95,6 @@ typedef struct {
|
||||
struct stats {
|
||||
unsigned long gets;
|
||||
unsigned long totalgets;
|
||||
unsigned long blocks;
|
||||
unsigned long freefrags;
|
||||
};
|
||||
|
||||
#define MEM_MAGIC ISC_MAGIC('M', 'e', 'm', 'C')
|
||||
@@ -126,9 +120,8 @@ struct isc__mem {
|
||||
isc_memalloc_t memalloc;
|
||||
isc_memfree_t memfree;
|
||||
void * arg;
|
||||
size_t max_size;
|
||||
bool checkfree;
|
||||
struct stats * stats;
|
||||
bool checkfree;
|
||||
struct stats stats;
|
||||
isc_refcount_t references;
|
||||
char name[16];
|
||||
void * tag;
|
||||
@@ -139,23 +132,13 @@ struct isc__mem {
|
||||
size_t maxmalloced;
|
||||
size_t hi_water;
|
||||
size_t lo_water;
|
||||
bool hi_called;
|
||||
bool is_overmem;
|
||||
bool hi_called;
|
||||
bool is_overmem;
|
||||
isc_mem_water_t water;
|
||||
void * water_arg;
|
||||
ISC_LIST(isc__mempool_t) pools;
|
||||
unsigned int poolcnt;
|
||||
|
||||
/* ISC_MEMFLAG_INTERNAL */
|
||||
size_t mem_target;
|
||||
element ** freelists;
|
||||
element * basic_blocks;
|
||||
unsigned char ** basic_table;
|
||||
unsigned int basic_table_count;
|
||||
unsigned int basic_table_size;
|
||||
unsigned char * lowest;
|
||||
unsigned char * highest;
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
debuglist_t * debuglist;
|
||||
size_t debuglistcnt;
|
||||
@@ -319,361 +302,40 @@ delete_trace_entry(isc__mem_t *mctx, const void *ptr, size_t size,
|
||||
}
|
||||
#endif /* ISC_MEM_TRACKLINES */
|
||||
|
||||
static inline size_t
|
||||
rmsize(size_t size) {
|
||||
/*
|
||||
* round down to ALIGNMENT_SIZE
|
||||
*/
|
||||
return (size & (~(ALIGNMENT_SIZE - 1)));
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
quantize(size_t size) {
|
||||
/*!
|
||||
* Round up the result in order to get a size big
|
||||
* enough to satisfy the request and be aligned on ALIGNMENT_SIZE
|
||||
* byte boundaries.
|
||||
*/
|
||||
|
||||
if (size == 0U)
|
||||
return (ALIGNMENT_SIZE);
|
||||
return ((size + ALIGNMENT_SIZE - 1) & (~(ALIGNMENT_SIZE - 1)));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
more_basic_blocks(isc__mem_t *ctx) {
|
||||
void *tmp;
|
||||
unsigned char *curr, *next;
|
||||
unsigned char *first, *last;
|
||||
unsigned char **table;
|
||||
unsigned int table_size;
|
||||
int i;
|
||||
|
||||
/* Require: we hold the context lock. */
|
||||
|
||||
INSIST(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 = (ctx->memalloc)(ctx->arg,
|
||||
table_size * sizeof(unsigned char *));
|
||||
RUNTIME_CHECK(table != NULL);
|
||||
ctx->malloced += table_size * sizeof(unsigned char *);
|
||||
if (ctx->malloced > ctx->maxmalloced)
|
||||
ctx->maxmalloced = ctx->malloced;
|
||||
if (ctx->basic_table_size != 0) {
|
||||
memmove(table, ctx->basic_table,
|
||||
ctx->basic_table_size *
|
||||
sizeof(unsigned char *));
|
||||
(ctx->memfree)(ctx->arg, ctx->basic_table);
|
||||
ctx->malloced -= ctx->basic_table_size *
|
||||
sizeof(unsigned char *);
|
||||
}
|
||||
ctx->basic_table = table;
|
||||
ctx->basic_table_size = table_size;
|
||||
}
|
||||
|
||||
tmp = (ctx->memalloc)(ctx->arg, NUM_BASIC_BLOCKS * ctx->mem_target);
|
||||
RUNTIME_CHECK(tmp != NULL);
|
||||
ctx->total += NUM_BASIC_BLOCKS * ctx->mem_target;;
|
||||
ctx->basic_table[ctx->basic_table_count] = tmp;
|
||||
ctx->basic_table_count++;
|
||||
ctx->malloced += NUM_BASIC_BLOCKS * ctx->mem_target;
|
||||
if (ctx->malloced > ctx->maxmalloced)
|
||||
ctx->maxmalloced = ctx->malloced;
|
||||
|
||||
curr = tmp;
|
||||
next = curr + ctx->mem_target;
|
||||
for (i = 0; i < (NUM_BASIC_BLOCKS - 1); i++) {
|
||||
((element *)curr)->next = (element *)next;
|
||||
curr = next;
|
||||
next += ctx->mem_target;
|
||||
}
|
||||
/*
|
||||
* curr is now pointing at the last block in the
|
||||
* array.
|
||||
*/
|
||||
((element *)curr)->next = NULL;
|
||||
first = tmp;
|
||||
last = first + NUM_BASIC_BLOCKS * ctx->mem_target - 1;
|
||||
if (first < ctx->lowest || ctx->lowest == NULL)
|
||||
ctx->lowest = first;
|
||||
if (last > ctx->highest)
|
||||
ctx->highest = last;
|
||||
ctx->basic_blocks = tmp;
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
more_frags(isc__mem_t *ctx, size_t new_size) {
|
||||
int i, frags;
|
||||
size_t total_size;
|
||||
void *tmp;
|
||||
unsigned char *curr, *next;
|
||||
|
||||
/*!
|
||||
* Try to get more fragments by chopping up a basic block.
|
||||
*/
|
||||
|
||||
if (ctx->basic_blocks == NULL) {
|
||||
if (!more_basic_blocks(ctx)) {
|
||||
/*
|
||||
* We can't get more memory from the OS, or we've
|
||||
* hit the quota for this context.
|
||||
*/
|
||||
/*
|
||||
* XXXRTH "At quota" notification here.
|
||||
*/
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
total_size = ctx->mem_target;
|
||||
tmp = ctx->basic_blocks;
|
||||
ctx->basic_blocks = ctx->basic_blocks->next;
|
||||
frags = (int)(total_size / new_size);
|
||||
ctx->stats[new_size].blocks++;
|
||||
ctx->stats[new_size].freefrags += frags;
|
||||
/*
|
||||
* Set up a linked-list of blocks of size
|
||||
* "new_size".
|
||||
*/
|
||||
curr = tmp;
|
||||
next = curr + new_size;
|
||||
total_size -= new_size;
|
||||
for (i = 0; i < (frags - 1); i++) {
|
||||
((element *)curr)->next = (element *)next;
|
||||
curr = next;
|
||||
next += new_size;
|
||||
total_size -= new_size;
|
||||
}
|
||||
/*
|
||||
* Add the remaining fragment of the basic block to a free list.
|
||||
*/
|
||||
total_size = rmsize(total_size);
|
||||
if (total_size > 0U) {
|
||||
((element *)next)->next = ctx->freelists[total_size];
|
||||
ctx->freelists[total_size] = (element *)next;
|
||||
ctx->stats[total_size].freefrags++;
|
||||
}
|
||||
/*
|
||||
* curr is now pointing at the last block in the
|
||||
* array.
|
||||
*/
|
||||
((element *)curr)->next = NULL;
|
||||
ctx->freelists[new_size] = tmp;
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
mem_getunlocked(isc__mem_t *ctx, size_t size) {
|
||||
size_t new_size = quantize(size);
|
||||
void *ret;
|
||||
|
||||
if (new_size >= ctx->max_size) {
|
||||
/*
|
||||
* memget() was called on something beyond our upper limit.
|
||||
*/
|
||||
ret = (ctx->memalloc)(ctx->arg, size);
|
||||
RUNTIME_CHECK(ret != NULL);
|
||||
ctx->total += size;
|
||||
ctx->inuse += size;
|
||||
ctx->stats[ctx->max_size].gets++;
|
||||
ctx->stats[ctx->max_size].totalgets++;
|
||||
ctx->malloced += size;
|
||||
if (ctx->malloced > ctx->maxmalloced)
|
||||
ctx->maxmalloced = ctx->malloced;
|
||||
/*
|
||||
* If we don't set new_size to size, then the
|
||||
* ISC_MEMFLAG_FILL code might write over bytes we don't
|
||||
* own.
|
||||
*/
|
||||
new_size = size;
|
||||
goto done;
|
||||
ret = (ctx->memalloc)(ctx->arg, size);
|
||||
RUNTIME_CHECK(ret != NULL);
|
||||
ctx->total += size;
|
||||
ctx->inuse += size;
|
||||
ctx->stats.gets++;
|
||||
ctx->stats.totalgets++;
|
||||
ctx->malloced += size;
|
||||
if (ctx->malloced > ctx->maxmalloced) {
|
||||
ctx->maxmalloced = ctx->malloced;
|
||||
}
|
||||
/*
|
||||
* If there are no blocks in the free list for this size, get a chunk
|
||||
* of memory and then break it up into "new_size"-sized blocks, adding
|
||||
* them to the free list.
|
||||
*/
|
||||
if (ctx->freelists[new_size] == NULL && !more_frags(ctx, new_size))
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* The free list uses the "rounded-up" size "new_size".
|
||||
*/
|
||||
|
||||
ret = ctx->freelists[new_size];
|
||||
ctx->freelists[new_size] = ctx->freelists[new_size]->next;
|
||||
|
||||
|
||||
/*
|
||||
* The stats[] uses the _actual_ "size" requested by the
|
||||
* caller, with the caveat (in the code above) that "size" >= the
|
||||
* max. size (max_size) ends up getting recorded as a call to
|
||||
* max_size.
|
||||
*/
|
||||
ctx->stats[size].gets++;
|
||||
ctx->stats[size].totalgets++;
|
||||
ctx->stats[new_size].freefrags--;
|
||||
ctx->inuse += new_size;
|
||||
|
||||
done:
|
||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0) &&
|
||||
ISC_LIKELY(ret != NULL))
|
||||
memset(ret, 0xbe, new_size); /* Mnemonic for "beef". */
|
||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
|
||||
memset(ret, 0xbe, size); /* Mnemonic for "beef". */
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#if ISC_MEM_CHECKOVERRUN
|
||||
static inline void
|
||||
check_overrun(void *mem, size_t size, size_t new_size) {
|
||||
unsigned char *cp;
|
||||
|
||||
cp = (unsigned char *)mem;
|
||||
cp += size;
|
||||
while (size < new_size) {
|
||||
INSIST(*cp == 0xbe);
|
||||
cp++;
|
||||
size++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* coverity[+free : arg-1] */
|
||||
static inline void
|
||||
mem_putunlocked(isc__mem_t *ctx, void *mem, size_t size) {
|
||||
size_t new_size = quantize(size);
|
||||
|
||||
if (new_size >= ctx->max_size) {
|
||||
/*
|
||||
* memput() called on something beyond our upper limit.
|
||||
*/
|
||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0))
|
||||
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
||||
|
||||
(ctx->memfree)(ctx->arg, mem);
|
||||
INSIST(ctx->stats[ctx->max_size].gets != 0U);
|
||||
ctx->stats[ctx->max_size].gets--;
|
||||
INSIST(size <= ctx->inuse);
|
||||
ctx->inuse -= size;
|
||||
ctx->malloced -= size;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
|
||||
#if ISC_MEM_CHECKOVERRUN
|
||||
check_overrun(mem, size, new_size);
|
||||
#endif
|
||||
memset(mem, 0xde, new_size); /* Mnemonic for "dead". */
|
||||
}
|
||||
|
||||
/*
|
||||
* The free list uses the "rounded-up" size "new_size".
|
||||
*/
|
||||
((element *)mem)->next = ctx->freelists[new_size];
|
||||
ctx->freelists[new_size] = (element *)mem;
|
||||
|
||||
/*
|
||||
* The stats[] uses the _actual_ "size" requested by the
|
||||
* caller, with the caveat (in the code above) that "size" >= the
|
||||
* max. size (max_size) ends up getting recorded as a call to
|
||||
* max_size.
|
||||
*/
|
||||
INSIST(ctx->stats[size].gets != 0U);
|
||||
ctx->stats[size].gets--;
|
||||
ctx->stats[new_size].freefrags++;
|
||||
ctx->inuse -= new_size;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Perform a malloc, doing memory filling and overrun detection as necessary.
|
||||
*/
|
||||
static inline void *
|
||||
mem_get(isc__mem_t *ctx, size_t size) {
|
||||
char *ret;
|
||||
|
||||
#if ISC_MEM_CHECKOVERRUN
|
||||
size += 1;
|
||||
#endif
|
||||
ret = (ctx->memalloc)(ctx->arg, size);
|
||||
RUNTIME_CHECK(ret != NULL);
|
||||
|
||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) {
|
||||
if (ISC_LIKELY(ret != NULL))
|
||||
memset(ret, 0xbe, size); /* Mnemonic for "beef". */
|
||||
}
|
||||
#if ISC_MEM_CHECKOVERRUN
|
||||
else {
|
||||
if (ISC_LIKELY(ret != NULL))
|
||||
ret[size-1] = 0xbe;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Perform a free, doing memory filling and overrun detection as necessary.
|
||||
*/
|
||||
/* coverity[+free : arg-1] */
|
||||
static inline void
|
||||
mem_put(isc__mem_t *ctx, void *mem, size_t size) {
|
||||
#if ISC_MEM_CHECKOVERRUN
|
||||
INSIST(((unsigned char *)mem)[size] == 0xbe);
|
||||
size += 1;
|
||||
#endif
|
||||
if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0))
|
||||
memset(mem, 0xde, size); /* Mnemonic for "dead". */
|
||||
}
|
||||
|
||||
(ctx->memfree)(ctx->arg, mem);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Update internal counters after a memory get.
|
||||
*/
|
||||
static inline void
|
||||
mem_getstats(isc__mem_t *ctx, size_t size) {
|
||||
ctx->total += size;
|
||||
ctx->inuse += size;
|
||||
|
||||
if (size > ctx->max_size) {
|
||||
ctx->stats[ctx->max_size].gets++;
|
||||
ctx->stats[ctx->max_size].totalgets++;
|
||||
} else {
|
||||
ctx->stats[size].gets++;
|
||||
ctx->stats[size].totalgets++;
|
||||
}
|
||||
|
||||
#if ISC_MEM_CHECKOVERRUN
|
||||
size += 1;
|
||||
#endif
|
||||
ctx->malloced += size;
|
||||
if (ctx->malloced > ctx->maxmalloced)
|
||||
ctx->maxmalloced = ctx->malloced;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Update internal counters after a memory put.
|
||||
*/
|
||||
static inline void
|
||||
mem_putstats(isc__mem_t *ctx, void *ptr, size_t size) {
|
||||
UNUSED(ptr);
|
||||
|
||||
INSIST(ctx->inuse >= size);
|
||||
INSIST(ctx->stats.gets != 0U);
|
||||
ctx->stats.gets--;
|
||||
INSIST(size <= ctx->inuse);
|
||||
ctx->inuse -= size;
|
||||
|
||||
if (size > ctx->max_size) {
|
||||
INSIST(ctx->stats[ctx->max_size].gets > 0U);
|
||||
ctx->stats[ctx->max_size].gets--;
|
||||
} else {
|
||||
INSIST(ctx->stats[size].gets > 0U);
|
||||
ctx->stats[size].gets--;
|
||||
}
|
||||
#if ISC_MEM_CHECKOVERRUN
|
||||
size += 1;
|
||||
#endif
|
||||
ctx->malloced -= size;
|
||||
}
|
||||
|
||||
@@ -730,8 +392,7 @@ initialize_action(void) {
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
||||
isc_mem_createx(isc_memalloc_t memalloc, isc_memfree_t memfree, void *arg,
|
||||
isc_mem_t **ctxp, unsigned int flags)
|
||||
{
|
||||
isc__mem_t *ctx;
|
||||
@@ -748,14 +409,8 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
ctx = (memalloc)(arg, sizeof(*ctx));
|
||||
RUNTIME_CHECK(ctx != NULL);
|
||||
|
||||
if ((flags & ISC_MEMFLAG_NOLOCK) == 0) {
|
||||
isc_mutex_init(&ctx->lock);
|
||||
}
|
||||
isc_mutex_init(&ctx->lock);
|
||||
|
||||
if (init_max_size == 0U)
|
||||
ctx->max_size = DEF_MAX_SIZE;
|
||||
else
|
||||
ctx->max_size = init_max_size;
|
||||
ctx->flags = flags;
|
||||
isc_refcount_init(&ctx->references, 1);
|
||||
memset(ctx->name, 0, sizeof(ctx->name));
|
||||
@@ -777,7 +432,8 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
ctx->memalloc = memalloc;
|
||||
ctx->memfree = memfree;
|
||||
ctx->arg = arg;
|
||||
ctx->stats = NULL;
|
||||
ctx->stats.gets = 0;
|
||||
ctx->stats.totalgets = 0;
|
||||
ctx->checkfree = true;
|
||||
#if ISC_MEM_TRACKLINES
|
||||
ctx->debuglist = NULL;
|
||||
@@ -785,35 +441,6 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
|
||||
#endif
|
||||
ISC_LIST_INIT(ctx->pools);
|
||||
ctx->poolcnt = 0;
|
||||
ctx->freelists = NULL;
|
||||
ctx->basic_blocks = NULL;
|
||||
ctx->basic_table = NULL;
|
||||
ctx->basic_table_count = 0;
|
||||
ctx->basic_table_size = 0;
|
||||
ctx->lowest = NULL;
|
||||
ctx->highest = NULL;
|
||||
|
||||
ctx->stats = (memalloc)(arg,
|
||||
(ctx->max_size+1) * sizeof(struct stats));
|
||||
RUNTIME_CHECK(ctx->stats != NULL);
|
||||
|
||||
memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof(struct stats));
|
||||
ctx->malloced += (ctx->max_size+1) * sizeof(struct stats);
|
||||
ctx->maxmalloced += (ctx->max_size+1) * sizeof(struct stats);
|
||||
|
||||
if ((flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
if (target_size == 0U)
|
||||
ctx->mem_target = DEF_MEM_TARGET;
|
||||
else
|
||||
ctx->mem_target = target_size;
|
||||
ctx->freelists = (memalloc)(arg, ctx->max_size *
|
||||
sizeof(element *));
|
||||
RUNTIME_CHECK(ctx->freelists != NULL);
|
||||
memset(ctx->freelists, 0,
|
||||
ctx->max_size * sizeof(element *));
|
||||
ctx->malloced += ctx->max_size * sizeof(element *);
|
||||
ctx->maxmalloced += ctx->max_size * sizeof(element *);
|
||||
}
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0)) {
|
||||
@@ -875,40 +502,21 @@ destroy(isc__mem_t *ctx) {
|
||||
#endif
|
||||
|
||||
if (ctx->checkfree) {
|
||||
for (i = 0; i <= ctx->max_size; i++) {
|
||||
if (ctx->stats[i].gets != 0U) {
|
||||
fprintf(stderr,
|
||||
"Failing assertion due to probable "
|
||||
"leaked memory in context %p (\"%s\") "
|
||||
"(stats[%u].gets == %lu).\n",
|
||||
ctx, ctx->name, i, ctx->stats[i].gets);
|
||||
if (ctx->stats.gets != 0U) {
|
||||
fprintf(stderr,
|
||||
"Failing assertion due to probable "
|
||||
"leaked memory in context %p (\"%s\") "
|
||||
"(stats.gets == %lu).\n",
|
||||
ctx, ctx->name, ctx->stats.gets);
|
||||
#if ISC_MEM_TRACKLINES
|
||||
print_active(ctx, stderr);
|
||||
print_active(ctx, stderr);
|
||||
#endif
|
||||
INSIST(ctx->stats[i].gets == 0U);
|
||||
}
|
||||
INSIST(ctx->stats.gets == 0U);
|
||||
}
|
||||
}
|
||||
|
||||
(ctx->memfree)(ctx->arg, ctx->stats);
|
||||
ctx->malloced -= (ctx->max_size+1) * sizeof(struct stats);
|
||||
isc_mutex_destroy(&ctx->lock);
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
for (i = 0; i < ctx->basic_table_count; i++) {
|
||||
(ctx->memfree)(ctx->arg, ctx->basic_table[i]);
|
||||
ctx->malloced -= NUM_BASIC_BLOCKS * ctx->mem_target;
|
||||
}
|
||||
(ctx->memfree)(ctx->arg, ctx->freelists);
|
||||
ctx->malloced -= ctx->max_size * sizeof(element *);
|
||||
if (ctx->basic_table != NULL) {
|
||||
(ctx->memfree)(ctx->arg, ctx->basic_table);
|
||||
ctx->malloced -= ctx->basic_table_size *
|
||||
sizeof(unsigned char *);
|
||||
}
|
||||
}
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_NOLOCK) == 0)
|
||||
isc_mutex_destroy(&ctx->lock);
|
||||
ctx->malloced -= sizeof(*ctx);
|
||||
if (ctx->checkfree)
|
||||
INSIST(ctx->malloced == 0);
|
||||
@@ -975,12 +583,7 @@ isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
|
||||
|
||||
DELETE_TRACE(ctx, ptr, size, file, line);
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(ctx, ptr, size);
|
||||
} else {
|
||||
mem_putstats(ctx, ptr, size);
|
||||
mem_put(ctx, ptr, size);
|
||||
}
|
||||
mem_putunlocked(ctx, ptr, size);
|
||||
MCTXUNLOCK(ctx, &ctx->lock);
|
||||
|
||||
destroy:
|
||||
@@ -1028,15 +631,8 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
(ISC_MEM_DEBUGSIZE|ISC_MEM_DEBUGCTX)) != 0))
|
||||
return (isc__mem_allocate(ctx0, size FLARG_PASS));
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
MCTXLOCK(ctx, &ctx->lock);
|
||||
ptr = mem_getunlocked(ctx, size);
|
||||
} else {
|
||||
ptr = mem_get(ctx, size);
|
||||
MCTXLOCK(ctx, &ctx->lock);
|
||||
if (ptr != NULL)
|
||||
mem_getstats(ctx, size);
|
||||
}
|
||||
MCTXLOCK(ctx, &ctx->lock);
|
||||
ptr = mem_getunlocked(ctx, size);
|
||||
|
||||
ADD_TRACE(ctx, ptr, size, file, line);
|
||||
|
||||
@@ -1088,12 +684,7 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
||||
|
||||
DELETE_TRACE(ctx, ptr, size, file, line);
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(ctx, ptr, size);
|
||||
} else {
|
||||
mem_putstats(ctx, ptr, size);
|
||||
mem_put(ctx, ptr, size);
|
||||
}
|
||||
mem_putunlocked(ctx, ptr, size);
|
||||
|
||||
/*
|
||||
* The check against ctx->lo_water == 0 is for the condition
|
||||
@@ -1162,31 +753,19 @@ print_active(isc__mem_t *mctx, FILE *out) {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Print the stats[] on the stream "out" with suitable formatting.
|
||||
* Print the stats on the stream "out" with suitable formatting.
|
||||
*/
|
||||
void
|
||||
isc_mem_stats(isc_mem_t *ctx0, FILE *out) {
|
||||
isc__mem_t *ctx = (isc__mem_t *)ctx0;
|
||||
size_t i;
|
||||
const struct stats *s;
|
||||
const isc__mempool_t *pool;
|
||||
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
MCTXLOCK(ctx, &ctx->lock);
|
||||
|
||||
for (i = 0; i <= ctx->max_size; i++) {
|
||||
s = &ctx->stats[i];
|
||||
|
||||
if (s->totalgets == 0U && s->gets == 0U)
|
||||
continue;
|
||||
fprintf(out, "%s%5lu: %11lu gets, %11lu rem",
|
||||
(i == ctx->max_size) ? ">=" : " ",
|
||||
(unsigned long) i, s->totalgets, s->gets);
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0 &&
|
||||
(s->blocks != 0U || s->freefrags != 0U))
|
||||
fprintf(out, " (%lu bl, %lu ff)",
|
||||
s->blocks, s->freefrags);
|
||||
fputc('\n', out);
|
||||
if (ctx->stats.totalgets != 0U || ctx->stats.gets != 0U) {
|
||||
fprintf(out, "[Memory statistics]\n%11lu gets, %11lu rem\n",
|
||||
ctx->stats.totalgets, ctx->stats.gets);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1238,10 +817,7 @@ mem_allocateunlocked(isc_mem_t *ctx0, size_t size) {
|
||||
if (ISC_UNLIKELY((isc_mem_debugging & ISC_MEM_DEBUGCTX) != 0))
|
||||
size += ALIGNMENT_SIZE;
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0)
|
||||
si = mem_getunlocked(ctx, size);
|
||||
else
|
||||
si = mem_get(ctx, size);
|
||||
si = mem_getunlocked(ctx, size);
|
||||
|
||||
if (si == NULL)
|
||||
return (NULL);
|
||||
@@ -1263,8 +839,6 @@ isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
|
||||
MCTXLOCK(ctx, &ctx->lock);
|
||||
si = mem_allocateunlocked((isc_mem_t *)ctx, size);
|
||||
if (((ctx->flags & ISC_MEMFLAG_INTERNAL) == 0) && (si != NULL))
|
||||
mem_getstats(ctx, si[-1].u.size);
|
||||
|
||||
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
|
||||
if (ctx->hi_water != 0U && ctx->inuse > ctx->hi_water &&
|
||||
@@ -1357,12 +931,7 @@ isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
|
||||
|
||||
DELETE_TRACE(ctx, ptr, size, file, line);
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(ctx, si, size);
|
||||
} else {
|
||||
mem_putstats(ctx, si, size);
|
||||
mem_put(ctx, si, size);
|
||||
}
|
||||
mem_putunlocked(ctx, si, size);
|
||||
|
||||
/*
|
||||
* The check against ctx->lo_water == 0 is for the condition
|
||||
@@ -1661,12 +1230,7 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
item = mpctx->items;
|
||||
mpctx->items = item->next;
|
||||
|
||||
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(mctx, item, mpctx->size);
|
||||
} else {
|
||||
mem_putstats(mctx, item, mpctx->size);
|
||||
mem_put(mctx, item, mpctx->size);
|
||||
}
|
||||
mem_putunlocked(mctx, item, mpctx->size);
|
||||
}
|
||||
MCTXUNLOCK(mctx, &mctx->lock);
|
||||
|
||||
@@ -1729,13 +1293,7 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
*/
|
||||
MCTXLOCK(mctx, &mctx->lock);
|
||||
for (i = 0; i < mpctx->fillcount; i++) {
|
||||
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
item = mem_getunlocked(mctx, mpctx->size);
|
||||
} else {
|
||||
item = mem_get(mctx, mpctx->size);
|
||||
if (item != NULL)
|
||||
mem_getstats(mctx, mpctx->size);
|
||||
}
|
||||
item = mem_getunlocked(mctx, mpctx->size);
|
||||
if (ISC_UNLIKELY(item == NULL))
|
||||
break;
|
||||
item->next = mpctx->items;
|
||||
@@ -1806,12 +1364,7 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
*/
|
||||
if (mpctx->freecount >= mpctx->freemax) {
|
||||
MCTXLOCK(mctx, &mctx->lock);
|
||||
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(mctx, mem, mpctx->size);
|
||||
} else {
|
||||
mem_putstats(mctx, mem, mpctx->size);
|
||||
mem_put(mctx, mem, mpctx->size);
|
||||
}
|
||||
mem_putunlocked(mctx, mem, mpctx->size);
|
||||
MCTXUNLOCK(mctx, &mctx->lock);
|
||||
if (mpctx->lock != NULL)
|
||||
UNLOCK(mpctx->lock);
|
||||
@@ -2052,10 +1605,7 @@ xml_renderctx(isc__mem_t *ctx, summarystat_t *summary,
|
||||
TRY0(xmlTextWriterEndElement(writer)); /* name */
|
||||
}
|
||||
|
||||
summary->contextsize += sizeof(*ctx) +
|
||||
(ctx->max_size + 1) * sizeof(struct stats) +
|
||||
ctx->max_size * sizeof(element *) +
|
||||
ctx->basic_table_count * sizeof(char *);
|
||||
summary->contextsize += sizeof(*ctx);
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (ctx->debuglist != NULL) {
|
||||
summary->contextsize +=
|
||||
@@ -2101,20 +1651,6 @@ xml_renderctx(isc__mem_t *ctx, summarystat_t *summary,
|
||||
(uint64_t)ctx->maxmalloced));
|
||||
TRY0(xmlTextWriterEndElement(writer)); /* maxmalloced */
|
||||
|
||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "blocksize"));
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
summary->blocksize += ctx->basic_table_count *
|
||||
NUM_BASIC_BLOCKS * ctx->mem_target;
|
||||
TRY0(xmlTextWriterWriteFormatString(writer,
|
||||
"%" PRIu64 "",
|
||||
(uint64_t)
|
||||
ctx->basic_table_count *
|
||||
NUM_BASIC_BLOCKS *
|
||||
ctx->mem_target));
|
||||
} else
|
||||
TRY0(xmlTextWriterWriteFormatString(writer, "%s", "-"));
|
||||
TRY0(xmlTextWriterEndElement(writer)); /* blocksize */
|
||||
|
||||
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "pools"));
|
||||
TRY0(xmlTextWriterWriteFormatString(writer, "%u", ctx->poolcnt));
|
||||
TRY0(xmlTextWriterEndElement(writer)); /* pools */
|
||||
@@ -2227,16 +1763,10 @@ json_renderctx(isc__mem_t *ctx, summarystat_t *summary, json_object *array) {
|
||||
|
||||
MCTXLOCK(ctx, &ctx->lock);
|
||||
|
||||
summary->contextsize += sizeof(*ctx) +
|
||||
(ctx->max_size + 1) * sizeof(struct stats) +
|
||||
ctx->max_size * sizeof(element *) +
|
||||
ctx->basic_table_count * sizeof(char *);
|
||||
summary->contextsize += sizeof(*ctx);
|
||||
summary->total += ctx->total;
|
||||
summary->inuse += ctx->inuse;
|
||||
summary->malloced += ctx->malloced;
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0)
|
||||
summary->blocksize += ctx->basic_table_count *
|
||||
NUM_BASIC_BLOCKS * ctx->mem_target;
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (ctx->debuglist != NULL) {
|
||||
summary->contextsize +=
|
||||
@@ -2283,15 +1813,6 @@ json_renderctx(isc__mem_t *ctx, summarystat_t *summary, json_object *array) {
|
||||
CHECKMEM(obj);
|
||||
json_object_object_add(ctxobj, "maxmalloced", obj);
|
||||
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
uint64_t blocksize;
|
||||
blocksize = ctx->basic_table_count * NUM_BASIC_BLOCKS *
|
||||
ctx->mem_target;
|
||||
obj = json_object_new_int64(blocksize);
|
||||
CHECKMEM(obj);
|
||||
json_object_object_add(ctxobj, "blocksize", obj);
|
||||
}
|
||||
|
||||
obj = json_object_new_int64(ctx->poolcnt);
|
||||
CHECKMEM(obj);
|
||||
json_object_object_add(ctxobj, "pools", obj);
|
||||
@@ -2373,9 +1894,8 @@ isc_mem_renderjson(json_object *memobj) {
|
||||
#endif /* HAVE_JSON */
|
||||
|
||||
isc_result_t
|
||||
isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) {
|
||||
return (isc_mem_createx(init_max_size, target_size,
|
||||
default_memalloc, default_memfree,
|
||||
isc_mem_create(isc_mem_t **mctxp) {
|
||||
return (isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, mctxp, isc_mem_defaultflags));
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ isc_heap_delete_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_heap_create(mctx, compare, idx, 0, &heap);
|
||||
|
||||
@@ -52,7 +52,7 @@ test_ht_full(int bits, uintptr_t count) {
|
||||
isc_mem_t *mctx = NULL;
|
||||
uintptr_t i;
|
||||
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &mctx, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
@@ -206,7 +206,7 @@ test_ht_iterator() {
|
||||
unsigned char key[16];
|
||||
size_t tksize;
|
||||
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &mctx, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ isc_test_begin(FILE *logfile, bool start_managers,
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
|
||||
INSIST(mctx == NULL);
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_mem_create(&mctx));
|
||||
|
||||
if (logfile != NULL) {
|
||||
isc_logdestination_t destination;
|
||||
|
||||
@@ -40,7 +40,7 @@ lex_0xff(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_lex_create(mctx, 1024, &lex);
|
||||
@@ -74,7 +74,7 @@ lex_setline(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_lex_create(mctx, 1024, &lex);
|
||||
|
||||
@@ -94,7 +94,7 @@ isc_mem_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_create(0, 0, &localmctx);
|
||||
result = isc_mem_create(&localmctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_mempool_create(localmctx, 24, &mp1);
|
||||
@@ -168,9 +168,9 @@ isc_mem_test(void **state) {
|
||||
|
||||
isc_mem_destroy(&localmctx);
|
||||
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &localmctx,
|
||||
ISC_MEMFLAG_FILL | ISC_MEMFLAG_INTERNAL);
|
||||
ISC_MEMFLAG_FILL);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_mempool_create(localmctx, 2, &mp1);
|
||||
@@ -200,7 +200,7 @@ isc_mem_total_test(void **state) {
|
||||
|
||||
/* Local alloc, free */
|
||||
mctx2 = NULL;
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &mctx2, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto out;
|
||||
@@ -257,7 +257,7 @@ isc_mem_inuse_test(void **state) {
|
||||
UNUSED(state);
|
||||
|
||||
mctx2 = NULL;
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &mctx2, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto out;
|
||||
@@ -295,7 +295,7 @@ isc_mem_noflags_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &mctx2, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
isc_mem_debugging = 0;
|
||||
@@ -342,7 +342,7 @@ isc_mem_recordflag_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &mctx2, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
ptr = isc_mem_get(mctx2, 2048);
|
||||
@@ -387,7 +387,7 @@ isc_mem_traceflag_test(void **state) {
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_mem_createx(0, 0, default_memalloc, default_memfree,
|
||||
result = isc_mem_createx(default_memalloc, default_memfree,
|
||||
NULL, &mctx2, 0);
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
@@ -286,7 +286,7 @@ random_test(pvalue_func_t *func, isc_random_func test_func) {
|
||||
|
||||
tables_init();
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
m = 1000;
|
||||
|
||||
@@ -707,7 +707,7 @@ manytasks(void **state) {
|
||||
isc_condition_init(&cv);
|
||||
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_taskmgr_create(mctx, 4, 0, &taskmgr);
|
||||
|
||||
@@ -70,7 +70,7 @@ setup() {
|
||||
isc_result_t result;
|
||||
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_mem_create(&mctx));
|
||||
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
|
||||
+2
-2
@@ -3059,7 +3059,7 @@ get_clientmctx(ns_clientmgr_t *manager, isc_mem_t **mctxp) {
|
||||
* Caller must be holding the manager lock.
|
||||
*/
|
||||
if ((manager->sctx->options & NS_SERVER_CLIENTTEST) != 0) {
|
||||
result = isc_mem_create(0, 0, mctxp);
|
||||
result = isc_mem_create(mctxp);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
isc_mem_setname(*mctxp, "client", NULL);
|
||||
return (result);
|
||||
@@ -3073,7 +3073,7 @@ get_clientmctx(ns_clientmgr_t *manager, isc_mem_t **mctxp) {
|
||||
|
||||
clientmctx = manager->mctxpool[nextmctx];
|
||||
if (clientmctx == NULL) {
|
||||
result = isc_mem_create(0, 0, &clientmctx);
|
||||
result = isc_mem_create(&clientmctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_mem_setname(clientmctx, "client", NULL);
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ initialize(void) {
|
||||
|
||||
REQUIRE(initialize_done == false);
|
||||
|
||||
result = isc_mem_create(0, 0, &ns_g_mctx);
|
||||
result = isc_mem_create(&ns_g_mctx);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return;
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ ns_test_begin(FILE *logfile, bool start_managers) {
|
||||
}
|
||||
|
||||
INSIST(mctx == NULL);
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_mem_create(&mctx));
|
||||
|
||||
if (!dst_active) {
|
||||
CHECK(dst_lib_init(mctx, NULL));
|
||||
|
||||
@@ -215,7 +215,7 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp,
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_mem_create(0, 0, mctxp);
|
||||
result = isc_mem_create(mctxp);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ set_key(dns_client_t *client, char *keynamestr, char *keystr,
|
||||
isc_region_t r;
|
||||
dns_secalg_t alg;
|
||||
|
||||
result = isc_mem_create(0, 0, mctxp);
|
||||
result = isc_mem_create(mctxp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "failed to create mctx\n");
|
||||
exit(1);
|
||||
@@ -367,7 +367,7 @@ main(int argc, char *argv[]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "failed to crate mctx\n");
|
||||
exit(1);
|
||||
|
||||
@@ -97,7 +97,7 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp,
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_mem_create(0, 0, mctxp);
|
||||
result = isc_mem_create(mctxp);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ main(int argc, char *argv[]) {
|
||||
qmessage = NULL;
|
||||
rmessage = NULL;
|
||||
|
||||
result = isc_mem_create(0, 0, &mctx);
|
||||
result = isc_mem_create(&mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "failed to create a memory context\n");
|
||||
exit(1);
|
||||
|
||||
@@ -240,7 +240,7 @@ main(int argc, char *argv[]) {
|
||||
fprintf(stderr, "dns_lib_init failed: %u\n", result);
|
||||
exit(1);
|
||||
}
|
||||
result = isc_mem_create(0, 0, &umctx);
|
||||
result = isc_mem_create(&umctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "failed to crate mctx\n");
|
||||
exit(1);
|
||||
|
||||
Reference in New Issue
Block a user