Make libnet_smbconf_key_exists() use talloc_stackframe().
authorMichael Adam <obnox@samba.org>
Sun, 23 Dec 2007 23:53:22 +0000 (00:53 +0100)
committerMichael Adam <obnox@samba.org>
Sun, 23 Dec 2007 23:53:22 +0000 (00:53 +0100)
And not pass a talloc context.

Michael

source/libnet/libnet_conf.c
source/utils/net_conf.c

index d9a9e7de9b254466e9933b20508631314ec2f6d7..26e17f2ea3675d9a2aee5ac35af5f9ce0a7fff26 100644 (file)
@@ -62,24 +62,18 @@ done:
 /*
  * check if a subkey of KEY_SMBCONF of a given name exists
  */
-bool libnet_smbconf_key_exists(TALLOC_CTX *ctx, const char *subkeyname)
+bool libnet_smbconf_key_exists(const char *subkeyname)
 {
        bool ret = False;
        WERROR werr = WERR_OK;
-       TALLOC_CTX *mem_ctx;
-       struct registry_key *key;
-
-       if (!(mem_ctx = talloc_new(ctx))) {
-               d_fprintf(stderr, "ERROR: Out of memory...!\n");
-               goto done;
-       }
+       TALLOC_CTX *mem_ctx = talloc_stackframe();
+       struct registry_key *key = NULL;
 
        werr = libnet_smbconf_open_path_q(mem_ctx, subkeyname, REG_KEY_READ, &key);
        if (W_ERROR_IS_OK(werr)) {
                ret = True;
        }
 
-done:
        TALLOC_FREE(mem_ctx);
        return ret;
 }
@@ -257,7 +251,7 @@ WERROR libnet_smbconf_setparm(TALLOC_CTX *mem_ctx,
        WERROR werr;
        struct registry_key *key = NULL;
 
-       if (!libnet_smbconf_key_exists(mem_ctx, service)) {
+       if (!libnet_smbconf_key_exists(service)) {
                werr = libnet_smbconf_reg_createkey_internal(mem_ctx, service,
                                                             &key);
        } else {
@@ -279,7 +273,7 @@ WERROR libnet_smbconf_getparm(TALLOC_CTX *mem_ctx,
        WERROR werr;
        struct registry_key *key = NULL;
 
-       if (!libnet_smbconf_key_exists(mem_ctx, service)) {
+       if (!libnet_smbconf_key_exists(service)) {
                werr = WERR_NO_SUCH_SERVICE;
                goto done;
        }
@@ -308,7 +302,7 @@ WERROR libnet_smbconf_delparm(TALLOC_CTX *mem_ctx,
        struct registry_key *key = NULL;
        WERROR werr = WERR_OK;
 
-       if (!libnet_smbconf_key_exists(mem_ctx, service)) {
+       if (!libnet_smbconf_key_exists(service)) {
                return WERR_NO_SUCH_SERVICE;
        }
 
index f3f2321643160b0feada5661aa02ac9db2dbdde8..d09079c6f28d22e136dbf067675130bf4d688963 100644 (file)
@@ -340,7 +340,7 @@ static int import_process_service(TALLOC_CTX *ctx,
        if (opt_testmode) {
                d_printf("[%s]\n", servicename);
        } else {
-               if (libnet_smbconf_key_exists(tmp_ctx, servicename)) {
+               if (libnet_smbconf_key_exists(servicename)) {
                        werr = reg_delkey_internal(tmp_ctx, servicename);
                        if (!W_ERROR_IS_OK(werr)) {
                                goto done;
@@ -424,7 +424,7 @@ int net_conf_list(int argc, const char **argv)
                goto done;
        }
 
-       if (libnet_smbconf_key_exists(ctx, GLOBAL_NAME))  {
+       if (libnet_smbconf_key_exists(GLOBAL_NAME))  {
                werr = reg_openkey(ctx, base_key, GLOBAL_NAME,
                                   REG_KEY_READ, &sub_key);
                if (!W_ERROR_IS_OK(werr)) {