diff options
author | Garming Sam <garming@catalyst.net.nz> | 2014-01-17 10:30:37 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2014-02-20 10:11:06 +1300 |
commit | 1fb1f6bc0dad00d1eb2d1e2aff34e9d3b2714421 (patch) | |
tree | 93ec165ad1423688666d46399c1890a17cb99b15 /script/generate_param.py | |
parent | bce62e600085270f26053882c5a4e35f5fe4fb5e (diff) | |
download | samba-1fb1f6bc0dad00d1eb2d1e2aff34e9d3b2714421.tar.gz |
lib/param: handle non-constant strings properly by passing in a memory context
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Change-Id: Ic6bb1c709defd2b0f35fc7b877da0badca385776
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Nadezhda Ivanova <nivanova@samba.org>
Diffstat (limited to 'script/generate_param.py')
-rw-r--r-- | script/generate_param.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/script/generate_param.py b/script/generate_param.py index 4e04b3a45bf..7df097ec3ed 100644 --- a/script/generate_param.py +++ b/script/generate_param.py @@ -177,7 +177,7 @@ def make_lib_proto(path_in, path_out): continue output_string = "" - if parameter['constant'] or parameter['type'] == 'string': + if parameter['constant']: output_string += 'const ' param_type = mapping.get(parameter['type']) if param_type is None: @@ -186,12 +186,20 @@ def make_lib_proto(path_in, path_out): output_string += "lpcfg_%s" % parameter['function'] - if parameter['context'] == 'G': - output_string += '(struct loadparm_context *);\n' - elif parameter['context'] == 'S': - output_string += '(struct loadparm_service *, struct loadparm_service *);\n' + if parameter['type'] == 'string' and not parameter['constant']: + if parameter['context'] == 'G': + output_string += '(struct loadparm_context *, TALLOC_CTX *ctx);\n' + elif parameter['context'] == 'S': + output_string += '(struct loadparm_service *, struct loadparm_service *, TALLOC_CTX *ctx);\n' + else: + raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) else: - raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) + if parameter['context'] == 'G': + output_string += '(struct loadparm_context *);\n' + elif parameter['context'] == 'S': + output_string += '(struct loadparm_service *, struct loadparm_service *);\n' + else: + raise Exception(parameter['name'] + " has an invalid param type " + parameter['type']) file_out.write(output_string) @@ -277,9 +285,6 @@ def make_s3_param(path_in, path_out): continue if parameter['context'] != 'G': continue - # STRING isn't handle yet properly - if parameter['type'] == 'string' and not parameter['constant']: - continue output_string = "\t" if parameter['constant'] or parameter['type'] == 'string': output_string += 'const ' @@ -288,7 +293,10 @@ def make_s3_param(path_in, path_out): raise Exception(parameter['name'] + " has an invalid context " + parameter['context']) output_string += param_type - output_string += " (*%s)(void);\n" % parameter['function'] + if parameter['type'] == 'string' and not parameter['constant']: + output_string += " (*%s)(TALLOC_CTX *);\n" % parameter['function'] + else: + output_string += " (*%s)(void);\n" % parameter['function'] file_out.write(output_string) file_out.write("};\n") @@ -321,9 +329,6 @@ def make_s3_param_ctx_table(path_in, path_out): continue if parameter['context'] != 'G': continue - # STRING isn't handle yet properly - if parameter['type'] == 'string' and not parameter['constant']: - continue output_string = "\t.%s" % parameter['function'] output_string += " = lp_%s,\n" % parameter['function'] file_out.write(output_string) |