142142parser_module_add_export_node_to_context (parser_context_t * context_p ) /**< parser context */
143143{
144144 ecma_module_node_t * module_node_p = context_p -> module_current_node_p ;
145+ context_p -> module_current_node_p = NULL ;
145146 ecma_module_node_t * * export_list_p ;
146147
147148 /* Check which list we should add it to. */
@@ -181,16 +182,18 @@ parser_module_add_export_node_to_context (parser_context_t *context_p) /**< pars
181182
182183 module_names_p -> next_p = stored_exports_p -> module_names_p ;
183184 stored_exports_p -> module_names_p = module_node_p -> module_names_p ;
185+ module_node_p -> module_names_p = NULL ;
184186 }
187+
188+ ecma_module_release_module_nodes (module_node_p );
185189 return ;
186190 }
187191
188192 stored_exports_p = stored_exports_p -> next_p ;
189193 }
190194
191- ecma_module_node_t * export_node_p = parser_module_create_module_node (context_p , module_node_p );
192- export_node_p -> next_p = * export_list_p ;
193- * export_list_p = export_node_p ;
195+ module_node_p -> next_p = * export_list_p ;
196+ * export_list_p = module_node_p ;
194197} /* parser_module_add_export_node_to_context */
195198
196199/**
200203parser_module_add_import_node_to_context (parser_context_t * context_p ) /**< parser context */
201204{
202205 ecma_module_node_t * module_node_p = context_p -> module_current_node_p ;
206+ context_p -> module_current_node_p = NULL ;
203207 ecma_module_node_t * stored_imports = JERRY_CONTEXT (module_top_context_p )-> imports_p ;
204208
205209 /* Check if we have a node with the same module request, append to it if we do. */
@@ -218,16 +222,18 @@ parser_module_add_import_node_to_context (parser_context_t *context_p) /**< pars
218222
219223 module_names_p -> next_p = stored_imports -> module_names_p ;
220224 stored_imports -> module_names_p = module_node_p -> module_names_p ;
225+ module_node_p -> module_names_p = NULL ;
221226 }
227+
228+ ecma_module_release_module_nodes (module_node_p );
222229 return ;
223230 }
224231
225232 stored_imports = stored_imports -> next_p ;
226233 }
227234
228- ecma_module_node_t * permanent_node_p = parser_module_create_module_node (context_p , module_node_p );
229- permanent_node_p -> next_p = JERRY_CONTEXT (module_top_context_p )-> imports_p ;
230- JERRY_CONTEXT (module_top_context_p )-> imports_p = permanent_node_p ;
235+ module_node_p -> next_p = JERRY_CONTEXT (module_top_context_p )-> imports_p ;
236+ JERRY_CONTEXT (module_top_context_p )-> imports_p = module_node_p ;
231237} /* parser_module_add_import_node_to_context */
232238
233239/**
@@ -305,21 +311,10 @@ parser_module_context_init (void)
305311 * - otherwise: an empty node.
306312 */
307313ecma_module_node_t *
308- parser_module_create_module_node (parser_context_t * context_p , /**< parser context */
309- ecma_module_node_t * template_node_p ) /**< template node for the new node */
314+ parser_module_create_module_node (parser_context_t * context_p ) /**< parser context */
310315{
311316 ecma_module_node_t * node_p = (ecma_module_node_t * ) parser_malloc (context_p , sizeof (ecma_module_node_t ));
312-
313- if (template_node_p != NULL )
314- {
315- node_p -> module_names_p = template_node_p -> module_names_p ;
316- node_p -> module_request_p = template_node_p -> module_request_p ;
317- node_p -> next_p = NULL ;
318- }
319- else
320- {
321- memset (node_p , 0 , sizeof (ecma_module_node_t ));
322- }
317+ memset (node_p , 0 , sizeof (ecma_module_node_t ));
323318
324319 return node_p ;
325320} /* parser_module_create_module_node */
0 commit comments