Commit 30b6e93a authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Merge branch 'ondrej/refactor-and-cleanup-isc_mem_create' into 'master'

Refactor and cleanup isc_mem_create()

See merge request !2315
parents 3be71081 aeea5ece
......@@ -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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment