Commit 4957255d authored by Ondřej Surý's avatar Ondřej Surý

Use the semantic patch to change the usage isc_mem_create() to new API

parent 6bd2eb06
......@@ -127,9 +127,7 @@ add(char *key, int value) {
isc_symvalue_t symvalue;
if (sym_mctx == NULL) {
result = isc_mem_create(0, 0, &sym_mctx);
if (result != ISC_R_SUCCESS)
return;
isc_mem_create(&sym_mctx);
}
if (symtab == NULL) {
......
......@@ -585,7 +585,7 @@ main(int argc, char **argv) {
}
isc_commandline_reset = true;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx);
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));
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));
isc_mem_create(&mctx);
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
generate_key(mctx, alg, keysize, &key_txtbuffer);
......
......@@ -1642,9 +1642,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);
if (result != ISC_R_SUCCESS)
fatal("failed to create mctx");
isc_mem_create(&mctx);
CHECK(isc_appctx_create(mctx, &actx));
CHECK(isc_taskmgr_createinctx(mctx, 1, 0, &taskmgr));
......
......@@ -1365,8 +1365,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);
check_result(result, "isc_mem_create");
isc_mem_create(&mctx);
isc_mem_setname(mctx, "dig", NULL);
result = isc_log_create(mctx, &lctx, &logconfig);
......
......@@ -1074,10 +1074,7 @@ main(int argc, char *argv[]) {
int ch;
char *endp;
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS) {
fatal("out of memory");
}
isc_mem_create(&mctx);
#if USE_PKCS11
pk11_result_register();
......
......@@ -350,10 +350,7 @@ main(int argc, char **argv) {
usage();
}
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS) {
fatal("out of memory");
}
isc_mem_create(&mctx);
#if USE_PKCS11
pk11_result_register();
......
......@@ -300,9 +300,7 @@ main(int argc, char **argv) {
if (argc == 1)
usage();
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS)
fatal("out of memory");
isc_mem_create(&mctx);
#if USE_PKCS11
pk11_result_register();
......
......@@ -163,7 +163,7 @@ main(int argc, char **argv) {
if (argc == 1)
usage();
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
#if USE_PKCS11
pk11_result_register();
......
......@@ -259,7 +259,7 @@ main(int argc, char **argv) {
}
isc_commandline_reset = true;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
isc_stdtime_get(&now);
......
......@@ -88,9 +88,7 @@ main(int argc, char **argv) {
if (argc == 1)
usage();
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS)
fatal("Out of memory");
isc_mem_create(&mctx);
#if HAVE_PKCS11
pk11_result_register();
......
......@@ -167,9 +167,7 @@ main(int argc, char **argv) {
if (argc == 1)
usage();
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS)
fatal("Out of memory");
isc_mem_create(&mctx);
setup_logging(mctx, &log);
......
......@@ -3230,9 +3230,7 @@ main(int argc, char *argv[]) {
check_result(isc_app_start(), "isc_app_start");
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS)
fatal("out of memory");
isc_mem_create(&mctx);
#if USE_PKCS11
pk11_result_register();
......
......@@ -209,9 +209,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);
if (result != ISC_R_SUCCESS)
fatal("out of memory");
isc_mem_create(&mctx);
#if USE_PKCS11
pk11_result_register();
......
......@@ -1462,10 +1462,7 @@ main(int argc, char *argv[]) {
named_g_chrootdir);
}
result = isc_mem_create(0, 0, &named_g_mctx);
if (result != ISC_R_SUCCESS)
named_main_earlyfatal("isc_mem_create() failed: %s",
isc_result_totext(result));
isc_mem_create(&named_g_mctx);
isc_mem_setname(named_g_mctx, "main", NULL);
setup();
......
......@@ -4349,9 +4349,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));
isc_mem_create(&cmctx);
isc_mem_setname(cmctx, "cache", NULL);
CHECK(isc_mem_create(0, 0, &hmctx));
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,9 +225,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
return (ISC_R_FAILURE);
}
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS)
return (result);
isc_mem_create(&mctx);
cd = isc_mem_get(mctx, sizeof(*cd));
memset(cd, 0, sizeof(*cd));
......
......@@ -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));
memset(cd, 0, sizeof(*cd));
......
......@@ -3269,8 +3269,7 @@ main(int argc, char **argv) {
pre_parse_args(argc, argv);
result = isc_mem_create(0, 0, &gmctx);
check_result(result, "isc_mem_create");
isc_mem_create(&gmctx);
parse_args(argc, argv);
......
......@@ -65,10 +65,7 @@ main(int argc, char *argv[]) {
exit(1);
}
if (isc_mem_create(0, 0, &mctx) != ISC_R_SUCCESS) {
fprintf(stderr, "isc_mem_create() failed\n");
exit(1);
}
isc_mem_create(&mctx);
pk11_result_register();
......
......@@ -930,7 +930,7 @@ main(int argc, char **argv) {
serial = isc_random32();
DO("create memory context", isc_mem_create(0, 0, &rndc_mctx));
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));
......
......@@ -70,7 +70,7 @@ main(int argc, char **argv) {
unsigned int zonetype = 0;
unsigned int pflags = 0;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
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));
isc_mem_create(&mctx);
CHECK(dst_lib_init(mctx, NULL));
dst_active = true;
......
......@@ -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);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx);
while ((ch = isc_commandline_parse(argc, argv, "d:vw:")) != -1) {
switch (ch) {
......
......@@ -362,7 +362,7 @@ main(int argc, char *argv[]) {
dns_result_register();
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
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));
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);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx);
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));
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);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx);
mp1 = NULL;
RUNTIME_CHECK(isc_mempool_create(mctx, 24, &mp1) == ISC_R_SUCCESS);
......
......@@ -186,12 +186,10 @@ nsecify(char *filename) {
int
main(int argc, char *argv[]) {
int i;
isc_result_t result;
dns_result_register();
result = isc_mem_create(0, 0, &mctx);
check_result(result, "isc_mem_create()");
isc_mem_create(&mctx);
argc--;
argv++;
......
......@@ -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);
isc_mem_create(&mctx);
RUNTIME_CHECK(isc_taskmgr_create(mctx, 3, 0, &taskmgr) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) ==
......
......@@ -277,12 +277,7 @@ main(int argc, char **argv) {
*/
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
result = isc_mem_create(0, 0, &mctx);
if (result != ISC_R_SUCCESS) {
printf("isc_mem_create: %s: exiting\n",
dns_result_totext(result));
exit(1);
}
isc_mem_create(&mctx);
result = dns_rbt_create(mctx, delete_name, NULL, &rbt);
if (result != ISC_R_SUCCESS) {
......
......@@ -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);
isc_mem_create(&mctx);
mctx2 = NULL;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx2) == ISC_R_SUCCESS);
isc_mem_create(&mctx2);
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);
isc_mem_create(&mctx);
while ((ch = isc_commandline_parse(argc, argv, "vp:")) != -1) {
switch (ch) {
......
......@@ -286,7 +286,7 @@ main(int argc, char *argv[]) {
* EVERYTHING needs a memory context.
*/
mctx = NULL;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
/*
* 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);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx1);
RUNTIME_CHECK(isc_taskmgr_create(mctx1, workers, 0, &manager) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_timermgr_create(mctx1, &timgr) == ISC_R_SUCCESS);
......
......@@ -280,7 +280,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);
isc_mem_create(&mctx);
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));
isc_mem_create(&mctx);
lctx = NULL;
lcfg = NULL;
......
......@@ -101,7 +101,7 @@ main(int argc, char **argv) {
dns_result_register();
CHECK(isc_mem_create(0, 0, &mctx), "isc_mem_create()");
isc_mem_create(&mctx);
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));
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));
isc_mem_create(&mctx);
log = NULL;
logconfig = NULL;
......
......@@ -132,7 +132,7 @@ main(int argc, char *argv[]) {
}
isc_commandline_reset = true;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
switch (ch) {
......
......@@ -342,7 +342,7 @@ main(int argc, char *argv[]) {
if (argc < 1)
fatal("no file specified");
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_mem_create(&mctx);
dns_result_register();
......
......@@ -2015,7 +2015,7 @@ main(int argc, char *argv[]) {
preparse_args(argc, argv);
mctx = NULL;
RUNCHECK(isc_mem_create(0, 0, &mctx));
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);
isc_mem_create(&mctx);
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);
isc_mem_create(&mctx);
RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
/*
......
......@@ -668,11 +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);
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "unexpected error creating lexer\n");
return result;
}
isc_mem_create(&lex_mctx);
/* create lexer */
result = isc_lex_create(lex_mctx, 1500, &lexer);
......
......@@ -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));
isc_mem_create(&mctx);
CHECK(isc_lex_create(mctx, 64, &lex));
memset(specials, 0, sizeof(specials));
......
......@@ -28,7 +28,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
static isc_mem_t *mctx = NULL;