File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,8 +60,7 @@ void free_module(Module** mod)
6060 if ( (* mod )-> list_param .itens )
6161 free ( (* mod )-> list_param .itens );
6262
63- if ( (* mod )-> list_register .itens )
64- free ( (* mod )-> list_register .itens );
63+ delete_list_register ( & ((* mod )-> list_register ) );
6564
6665 if ( (* mod )-> sinais_input )
6766 free ( (* mod )-> sinais_input );
@@ -171,6 +170,25 @@ void delete_list_component(ListComponent** ppl)
171170 * ppl = NULL ;
172171}
173172
173+ void delete_list_register (ListRegister * list_reg )
174+ {
175+ if ( !list_reg || !list_reg -> itens )
176+ return ;
177+
178+ int i ;
179+
180+ for ( i = 0 ; i < list_reg -> total ; i ++ )
181+ {
182+ if ( list_reg -> itens [i ] ) {
183+ free ( list_reg -> itens [i ] );
184+ }
185+ }
186+
187+ free ( list_reg -> itens );
188+ list_reg -> itens = NULL ;
189+ list_reg -> total = 0 ;
190+ }
191+
174192void insert_component (ListComponent * ls , Component * cp )
175193{
176194 ls -> tamanho ++ ;
Original file line number Diff line number Diff line change @@ -280,6 +280,11 @@ ListComponent* new_list_component_of_size(unsigned int size);
280280 */
281281void delete_list_component (ListComponent * * ppl );
282282
283+ /** @brief Libera completamente uma lista de registradores da memória.
284+ * @param list_reg Ponteiro para a struct ListRegister a ser liberada.
285+ */
286+ void delete_list_register (ListRegister * list_reg );
287+
283288/** @brief Insere o componente na lista de componentes.
284289 * @param ls Ponteiro para a lista de componentes.
285290 * @param cp Ponteiro para o componente a ser inserido.
You can’t perform that action at this time.
0 commit comments