hi everyone I'm working currently with linked list , and there's a problem with my code , the link is writing the same place every time (it replaces the previous values with the new ones without inserting a new one ) can anyone help ? Thanks in advance
#include<stdio.h>
#include<unistd.h>
struct mem_chunk
{
unsigned *mem_break ;
int size ;
int required_size;
struct mem_chunk * next;
};
struct mem_chunk *used_chunks , *unused_chunks;
void insert( struct mem_chunk new_node , int flag)
{
if ( flag ==0 )
{
if (used_chunks == NULL )
{
used_chunks = &new_node;
}
else {
struct mem_chunk *current ;
current = used_chunks;
current=current->next;
current=&new_node;
}
}
}