DoubleLinkedList.h
#ifndef _DOUBLE_LINKED_LIST_H
#define _DOUBLE_LINKED_LIST_H
typedef unsigned int uint;
typedef unsigned long ulong;
typedef void* Object;
typedef struct _DNode {
Object data;
struct _DNode* prev;
struct _DNode* next;
}DNode;
typedef struct _DoubleLinkedList{
DNode* head;
DNode* tail;
uint length;
uint elementSize;
}DoubleLinkedList;
DoubleLinkedList* allocDList (uint elementSize);
#endif
DoubleLinkedList.c
#include "DoubleLinkedList.h"
DoubleLinkedList* allocDList (uint elementSize)
{
DoubleLinkedList* l;
l->head = NULL;
l->tail = NULL;
l->length = 0;
l->elementSize = elementSize;
return l;
}
main.c
#include <stdio.h>
#include "DoubleLinkedList.h"
int main ()
{
DoubleLinkedList* ab;
ab = allocDList(10);
return 0;
}
When I try to run this I get a segmentation fault with a core dump.
this is what is required in the assignment.
DoubleLinkedList* allocDList(uint elementSize): this function allocates the DoubleLinkList