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)
{
* 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)
}
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;
}
/* We have a new definition. */
else
- (void) macro_create(name, s, FALSE, FALSE);
+ (void) macro_create(string_copy(name), string_copy(s), FALSE, FALSE);
}
/* 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 */