From: Jeremy Harris Date: Sat, 8 Jul 2017 12:59:49 +0000 (+0100) Subject: Split macro name storage out from macro definition struct X-Git-Tag: exim-4_90_RC1~120 X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=commitdiff_plain;h=125103cef97f15a3e37430f3ca7c63d5802c7625 Split macro name storage out from macro definition struct --- diff --git a/src/src/exim.c b/src/src/exim.c index 88e119778..e816fd9c6 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -2457,7 +2457,7 @@ for (i = 1; i < argc; i++) exit(EXIT_FAILURE); } - m = macro_create(name, s, TRUE, FALSE); + m = macro_create(string_copy(name), string_copy(s), TRUE, FALSE); if (clmacro_count >= MAX_CLMACROS) { diff --git a/src/src/readconf.c b/src/src/readconf.c index eb44d1085..e0f9d2ddc 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -561,18 +561,21 @@ return US""; * Deal with an assignment to a macro * *************************************************/ -/* We have a new definition. The macro_item structure includes a final vector -called "name" which is one byte long. Thus, adding "namelen" gives us enough -room to store the "name" string. +/* We have a new definition. If a builtin macro we place at head of list, else tail. This lets us lazy-create -builtins. */ +builtins. + +Args: + name Name of the macro. Must be in storage persistent past the call + val Expansion result for the macro. Ditto persistence. +*/ macro_item * macro_create(const uschar * name, const uschar * val, BOOL command_line, BOOL builtin) { unsigned namelen = Ustrlen(name); -macro_item * m = store_get(sizeof(macro_item) + namelen); +macro_item * m = store_get(sizeof(macro_item)); /* fprintf(stderr, "%s: '%s' '%s'\n", __FUNCTION__, name, val) */ if (!macros) @@ -594,8 +597,8 @@ else } m->command_line = command_line; m->namelen = namelen; -m->replacement = string_copy(val); -Ustrcpy(m->name, name); +m->name = name; +m->replacement = val; return m; } @@ -689,7 +692,7 @@ if (redef) /* We have a new definition. */ else - (void) macro_create(name, s, FALSE, FALSE); + (void) macro_create(string_copy(name), string_copy(s), FALSE, FALSE); } diff --git a/src/src/structs.h b/src/src/structs.h index 474b85577..14d109869 100644 --- a/src/src/structs.h +++ b/src/src/structs.h @@ -28,11 +28,11 @@ struct router_info; /* Structure for remembering macros for the configuration file */ typedef struct macro_item { - struct macro_item *next; - BOOL command_line; - unsigned namelen; - uschar * replacement; - uschar name[1]; + struct macro_item * next; + BOOL command_line; + unsigned namelen; + const uschar * name; + const uschar * replacement; } macro_item; /* Structure for bit tables for debugging and logging */