diff options
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r-- | libcpp/macro.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c index cfc42b4050f..dc58b3180f1 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -1408,8 +1408,16 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro) if (!ok) return false; - /* Success. Commit the parameter array. */ - BUFF_FRONT (pfile->a_buff) = (uchar *) ¯o->params[macro->paramc]; + /* Success. Commit or allocate the parameter array. */ + if (pfile->hash_table->alloc_subobject) + { + cpp_token *tokns = pfile->hash_table->alloc_subobject + (sizeof (cpp_token) * macro->paramc); + memcpy (tokns, macro->params, sizeof (cpp_token) * macro->paramc); + macro->params = tokns; + } + else + BUFF_FRONT (pfile->a_buff) = (uchar *) ¯o->params[macro->paramc]; macro->fun_like = 1; } else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE)) @@ -1472,6 +1480,7 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro) } macro->exp.tokens = (cpp_token *) BUFF_FRONT (pfile->a_buff); + macro->traditional = 0; /* Don't count the CPP_EOF. */ macro->count--; @@ -1480,8 +1489,16 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro) if (macro->count) macro->exp.tokens[0].flags &= ~PREV_WHITE; - /* Commit the memory. */ - BUFF_FRONT (pfile->a_buff) = (uchar *) ¯o->exp.tokens[macro->count]; + /* Commit or allocate the memory. */ + if (pfile->hash_table->alloc_subobject) + { + cpp_token *tokns = pfile->hash_table->alloc_subobject (sizeof (cpp_token) + * macro->count); + memcpy (tokns, macro->exp.tokens, sizeof (cpp_token) * macro->count); + macro->exp.tokens = tokns; + } + else + BUFF_FRONT (pfile->a_buff) = (uchar *) ¯o->exp.tokens[macro->count]; return true; } @@ -1494,7 +1511,10 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node) unsigned int i; bool ok; - macro = (cpp_macro *) _cpp_aligned_alloc (pfile, sizeof (cpp_macro)); + if (pfile->hash_table->alloc_subobject) + macro = pfile->hash_table->alloc_subobject (sizeof (cpp_macro)); + else + macro = (cpp_macro *) _cpp_aligned_alloc (pfile, sizeof (cpp_macro)); macro->line = pfile->directive_line; macro->params = 0; macro->paramc = 0; |