diff options
author | Michael Adam <obnox@samba.org> | 2008-12-15 14:38:51 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2008-12-15 14:46:25 +0100 |
commit | c2bd88f145d73e9a8613d32d313954e3ecdcacd2 (patch) | |
tree | 99460fe9a71b7d19b9ca6335e75623488a9da8ed /source3/param | |
parent | 03f19dad795c247878918de95a8c1f63ec259d13 (diff) | |
download | samba-c2bd88f145d73e9a8613d32d313954e3ecdcacd2.tar.gz samba-c2bd88f145d73e9a8613d32d313954e3ecdcacd2.tar.bz2 samba-c2bd88f145d73e9a8613d32d313954e3ecdcacd2.zip |
s3:loadparm: add service-struct based variants of the free-parameter routines
and use the abstracted free_one_parameter_common() in old
free_one_parameter_by_snum() as well as in new free_one_parameter()
Michael
Diffstat (limited to 'source3/param')
-rw-r--r-- | source3/param/loadparm.c | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index d44d04a7a7..f2a39d12de 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4585,6 +4585,51 @@ static void init_printer_values(struct service *pService) } } +/** + * Common part of freeing allocated data for one parameter. + */ +static void free_one_parameter_common(void *parm_ptr, + struct parm_struct parm) +{ + if ((parm.type == P_STRING) || + (parm.type == P_USTRING)) + { + string_free((char**)parm_ptr); + } else if (parm.type == P_LIST) { + TALLOC_FREE(*((char***)parm_ptr)); + } +} + +/** + * Free the allocated data for one parameter for a share + * given as a service struct. + */ +static void free_one_parameter(struct service *service, + struct parm_struct parm) +{ + void *parm_ptr; + + if (parm.p_class != P_LOCAL) { + return; + } + + parm_ptr = lp_local_ptr(service, parm.ptr); + + free_one_parameter_common(parm_ptr, parm); +} + +/** + * Free the allocated parameter data of a share given + * as a service struct. + */ +static void free_parameters(struct service *service) +{ + uint32_t i; + + for (i=0; parm_table[i].label; i++) { + free_one_parameter(service, parm_table[i]); + } +} /** * Free the allocated data for one parameter for a given share @@ -4606,13 +4651,7 @@ static void free_one_parameter_by_snum(int snum, struct parm_struct parm) parm_ptr = lp_local_ptr_by_snum(snum, parm.ptr); } - if ((parm.type == P_STRING) || - (parm.type == P_USTRING)) - { - string_free((char**)parm_ptr); - } else if (parm.type == P_LIST) { - TALLOC_FREE(*((char***)parm_ptr)); - } + free_one_parameter_common(parm_ptr, parm); } /** |