summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2017-07-08 13:59:49 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2017-07-08 13:59:49 +0100
commit125103cef97f15a3e37430f3ca7c63d5802c7625 (patch)
tree3762e6fd7379a3438e7d841f7fb0a2337a716652 /src
parent503bf579576ca66c97b6b93a809cf6ca69ad04fd (diff)
Split macro name storage out from macro definition struct
Diffstat (limited to 'src')
-rw-r--r--src/src/exim.c2
-rw-r--r--src/src/readconf.c19
-rw-r--r--src/src/structs.h10
3 files changed, 17 insertions, 14 deletions
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 */