Skip to content

Commit

Permalink
loadparm: Add ctx member to struct loadparm_global.
Browse files Browse the repository at this point in the history
Rather than tallocing global parameters off NULL, keep it neat by having
a Global.ctx member.

Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Andrew Bartlett <[email protected]>
  • Loading branch information
rustyrussell authored and abartlet committed Aug 7, 2012
1 parent 9b7b736 commit 592e3f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion script/mkparamdefs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ ($$$)
$file->(" * This structure describes global (ie., server-wide) parameters.\n");
$file->(" */\n");
$file->("struct loadparm_global \n");
$file->("{\n");
$file->("\tTALLOC_CTX *ctx; /* Context for talloced members */\n");
} elsif ($generate_scope eq "LOCAL") {
$file->(" * This structure describes a single service.\n");
$file->(" */\n");
$file->("struct loadparm_service \n");
$file->("{\n");
}
$file->("{\n");
}

sub print_footer($$$)
Expand Down
3 changes: 3 additions & 0 deletions source3/param/loadparm.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ static void free_global_parameters(void)
{
free_param_opts(&Globals.param_opt);
free_parameters_by_snum(GLOBAL_SECTION_SNUM);
TALLOC_FREE(Globals.ctx);
}

static int map_parameter(const char *pszParmName);
Expand Down Expand Up @@ -690,6 +691,8 @@ static void init_globals(bool reinit_globals)
* table once the defaults are set */
ZERO_STRUCT(Globals);

Globals.ctx = talloc_new(NULL);

for (i = 0; parm_table[i].label; i++) {
if ((parm_table[i].type == P_STRING ||
parm_table[i].type == P_USTRING))
Expand Down

0 comments on commit 592e3f4

Please sign in to comment.