diff --git a/src/libraries/libisc-new/src/isc_master.c b/src/libraries/libisc-new/src/isc_master.c index 151f37c34f18e66cd8d2a8d29efa32f9a435c36a..3801263109df6a0565347925f674334b3593157e 100644 --- a/src/libraries/libisc-new/src/isc_master.c +++ b/src/libraries/libisc-new/src/isc_master.c @@ -27,23 +27,46 @@ isc_initialize(IscConfig * cfg) IscMasterConfig * mcfg; IscSessionConfig * scfg; - /* Make sure the mcb is allocated using the correct allocator. */ - if (cfg && cfg->version == 1005 && cfg->master.version == 1001) - { - if (cfg->master.memfn.alloc && cfg->master.memfn.realloc - && cfg->master.memfn.free) - { - isc_setallocfn(cfg->master.memfn.alloc, - cfg->master.memfn.realloc, - cfg->master.memfn.free); - } + + /* Handle user specified defaults */ + if (cfg) + switch (cfg->version) + { + case 0: + break; + + case 1005: + mcfg = &cfg->master; + + switch (mcfg->version) + { + case 0: + break; + + case 1001: + if (mcfg->memfn.alloc && + mcfg->memfn.realloc && + mcfg->memfn.free) + isc_setallocfn(mcfg->memfn.alloc, + mcfg->memfn.realloc, + mcfg->memfn.free); + if (mcfg->abortfn) + isc_setabortfn(mcfg->abortfn); + break; - if (cfg->master.abortfn) - isc_setabortfn(cfg->master.abortfn); - } + default: + errno = EINVAL; + return NULL; + } + break; + default: + errno = EINVAL; + return NULL; + } + ISC_XNEW(mcb); - + mcb->sessions = NULL; @@ -60,7 +83,6 @@ isc_initialize(IscConfig * cfg) { case 1005: scfg = &cfg->session; - mcfg = &cfg->master; switch (scfg->version) { @@ -86,27 +108,6 @@ isc_initialize(IscConfig * cfg) return NULL; } - switch (mcfg->version) - { - case 0: - break; - - case 1001: - if (mcfg->memfn.alloc && - mcfg->memfn.realloc && - mcfg->memfn.free) - isc_setallocfn(mcfg->memfn.alloc, - mcfg->memfn.realloc, - mcfg->memfn.free); - if (mcfg->abortfn) - isc_setabortfn(mcfg->abortfn); - break; - - default: - isc_free(mcb); - errno = EINVAL; - return NULL; - } break; default: