I'm trying to implement an replacement algorithm that deals with page faults. So i'm trying to creat a circular linked list using malloc and im getting the following error: "invalid application of sizeof' to incomplete type
pageInMemory'.following is the code:
typedef struct { int use; int reference; int free; struct pageInMemory* next; } pageInMemory; int main() { int i; struct pageInMemory* start, *nn, *temp, *hand; start = NULL; for(i=0; i< pNum; i++) { nn = (struct pageInMemory *)malloc(sizeof(struct pageInMemory)); nn->use = 0; nn->free = 1; if(start==NULL) { nn->next = nn; start =nn; } else { // sfhsdifhsdifj sdijfjsd temp = start; while(temp->next != start) { temp = temp->next; } temp->next = nn; nn->next = start; start = nn; } } hand = start; temp = start; while(temp->next != start->next) { printf("%d\n", temp->use); //hi } return 0;// bye }
so am i not supposed to use malloc this way ?