I'm trying to allocate memory for 10x of my list struct then use it for my linked list but I keep getting a segmentation fault.
Valgrind
==3806== Invalid write of size 4
==3806== at 0x4005FD: main (comp.c:14)
==3806== Address 0xffffffffffffffff is not stack'd, malloc'd or (recently) free'd
Sample Code
#include <sys/mman.h>
typedef struct list {
int num;
struct list *next;
}list;
int main()
{
list *nodes = mmap(NULL, sizeof(list) * 10, PROT_READ | PROT_WRITE, MAP_PRIVATE, -1, 0);
nodes[0].num = 1;
nodes[0].next = NULL;
}