mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	sv: fix a few struct and enum memory leaks
This commit is contained in:
		
							parent
							
								
									2b8f1633ce
								
							
						
					
					
						commit
						4446cfa524
					
				
					 2 changed files with 11 additions and 2 deletions
				
			
		|  | @ -331,6 +331,8 @@ static int size_packed_struct(AstNode *snode, int base_offset) | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				// range nodes are now redundant
 | 				// range nodes are now redundant
 | ||||||
|  | 				for (AstNode *child : node->children) | ||||||
|  | 					delete child; | ||||||
| 				node->children.clear(); | 				node->children.clear(); | ||||||
| 			} | 			} | ||||||
| 			else if (node->children.size() == 1 && node->children[0]->type == AST_MULTIRANGE) { | 			else if (node->children.size() == 1 && node->children[0]->type == AST_MULTIRANGE) { | ||||||
|  | @ -345,6 +347,8 @@ static int size_packed_struct(AstNode *snode, int base_offset) | ||||||
| 				save_struct_array_width(node, width); | 				save_struct_array_width(node, width); | ||||||
| 				width *= array_count; | 				width *= array_count; | ||||||
| 				// range nodes are now redundant
 | 				// range nodes are now redundant
 | ||||||
|  | 				for (AstNode *child : node->children) | ||||||
|  | 					delete child; | ||||||
| 				node->children.clear(); | 				node->children.clear(); | ||||||
| 			} | 			} | ||||||
| 			else if (node->range_left < 0) { | 			else if (node->range_left < 0) { | ||||||
|  | @ -5052,6 +5056,9 @@ finished: | ||||||
| void AstNode::allocateDefaultEnumValues() | void AstNode::allocateDefaultEnumValues() | ||||||
| { | { | ||||||
| 	log_assert(type==AST_ENUM); | 	log_assert(type==AST_ENUM); | ||||||
|  | 	log_assert(children.size() > 0); | ||||||
|  | 	if (children.front()->attributes.count(ID::enum_base_type)) | ||||||
|  | 		return; // already elaborated
 | ||||||
| 	int last_enum_int = -1; | 	int last_enum_int = -1; | ||||||
| 	for (auto node : children) { | 	for (auto node : children) { | ||||||
| 		log_assert(node->type==AST_ENUM_ITEM); | 		log_assert(node->type==AST_ENUM_ITEM); | ||||||
|  |  | ||||||
|  | @ -1711,10 +1711,12 @@ member_type_token: | ||||||
| 			delete astbuf1; | 			delete astbuf1; | ||||||
| 			astbuf1 = template_node; | 			astbuf1 = template_node; | ||||||
| 		} | 		} | ||||||
| 	| struct_union { | 	| { | ||||||
|  | 		delete astbuf1; | ||||||
|  | 	} struct_union { | ||||||
| 			// stash state on ast_stack | 			// stash state on ast_stack | ||||||
| 			ast_stack.push_back(astbuf2); | 			ast_stack.push_back(astbuf2); | ||||||
| 			astbuf2 = $1; | 			astbuf2 = $2; | ||||||
| 		} struct_body  { | 		} struct_body  { | ||||||
| 		        astbuf1 = astbuf2; | 		        astbuf1 = astbuf2; | ||||||
| 			// recover state | 			// recover state | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue