diff options
author | Volker Lendecke <vl@samba.org> | 2014-11-26 21:35:27 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-11-27 01:41:08 +0100 |
commit | 733422c611a72bcf8c53b423a466277c4b783941 (patch) | |
tree | eb02613d18a4451cf123662168db157875bd92eb | |
parent | 46f27a8f7824e08bf8e212a192e92b083bf59227 (diff) | |
download | samba-733422c611a72bcf8c53b423a466277c4b783941.tar.gz |
param: Simplify get_parametric_helper()
With variable sized arrays we don't need talloc_asprintf here
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Nov 27 01:41:09 CET 2014 on sn-devel-104
-rw-r--r-- | lib/param/loadparm.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 30b11555e3d..1a60b997b86 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -241,16 +241,12 @@ struct parmlist_entry *get_parametric_helper(struct loadparm_service *service, const char *type, const char *option, struct parmlist_entry *global_opts) { - char* param_key; + size_t type_len = strlen(type); + size_t option_len = strlen(option); + char param_key[type_len + option_len + 2]; struct parmlist_entry *data = NULL; - TALLOC_CTX *mem_ctx = talloc_stackframe(); - param_key = talloc_asprintf(mem_ctx, "%s:%s", type, option); - if (param_key == NULL) { - DEBUG(0,("asprintf failed!\n")); - TALLOC_FREE(mem_ctx); - return NULL; - } + snprintf(param_key, sizeof(param_key), "%s:%s", type, option); /* * Try to fetch the option from the data. @@ -259,7 +255,6 @@ struct parmlist_entry *get_parametric_helper(struct loadparm_service *service, data = service->param_opt; while (data != NULL) { if (strwicmp(data->key, param_key) == 0) { - TALLOC_FREE(mem_ctx); return data; } data = data->next; @@ -272,18 +267,12 @@ struct parmlist_entry *get_parametric_helper(struct loadparm_service *service, data = global_opts; while (data != NULL) { if (strwicmp(data->key, param_key) == 0) { - TALLOC_FREE(mem_ctx); return data; } data = data->next; } - - TALLOC_FREE(mem_ctx); - return NULL; - - } const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx, |