I changed the code, moved the memcpy into the if statment but i still get the same error.
** * Returns a new linked list node filled in with the given order, The function * allocates a new order and copy the values stored in data then allocate a * linked list node. If you are implementing this function make sure that you * duplicate, as the original data may be modified by the calling function. */
struct order
{
int id;
char side;
int quantity;
double price;
};
struct onode
{
struct order* data;
struct onode* next;
struct onode* prev;
};
struct onode* newNode (struct order* data)
{
struct order* dataValue = (struct order*) malloc(sizeof(struct order));
struct onode* linkedlist = (struct onode*) malloc(sizeof(struct onode));
if(data != NULL)
{
linkedlist ->data = dataValue;
memcpy(dataValue, data, sizeof(*dataValue));
}
else
{
return NULL;
}
linkedlist->prev = NULL;
linkedlist->next = NULL;
return linkedlist;
}