main: malloc.c:2405: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
When trying to produce a doubly linked list where the user can only add to the head or tail, I end up getting the lovely abortion message at the top.
I have used gdb to narrow it down to what function it is that is causing this, but I really don't know what I'm doing wrong. It allocates the first node, then after that, it throws me the error.
The function is as follows:
data* initD(){
data *D = NULL;
D = malloc(sizeof(data*));
if (!D){
printf("Error in allocation of data\n");
exit(0);
}
D->head = NULL;
D->tail = NULL;
D->next = NULL;
D->prev = NULL;
D->val = -1;
return D;
}
malloc(sizeof(data*))
? And what ifsizeof(data) != sizeof(data*)
(which seems quite likely considering your assignments later)?