Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
711 Views

soft reset nios won't deallocate memory

The following is a simplified version of my main function. It works fine until I asserted Nios' soft reset input several times. After asserting Nios' reset input several times, there was not enough memory to get allocated.  

I tried to put free() function right before return(1) at the end of main function and it didn't do anything. 

 

Any suggestion? 

 

Thanks. 

------------------------------------------------------------ 

 

int main() 

ITEMS *my_items; 

int command; 

 

if ((my_items = (ITEMS *) malloc(sizeof(ITEMS) * MAX_ITEMS)) == NULL) { 

printf("failed to allocate memory\r\n"); 

exit(-1); 

 

// tight loop to wait user's input to do something with ITEMS 

while (1) 

command = IORD_BLA_AVALON_COMMAND (BLA_0_BASE)); 

 

switch (command) 

case 1: set (my_items); break; 

case 2: save (my_items); break; 

case 3: read (my_items); break; 

default: break; 

return (1); 

}
0 Kudos