1
이 오류가 발생합니다. 도와주세요!포인터 및 연결된 목록 제거 기능이있는 호환되지 않는 유형
3.C : 함수 메인 :
3.C : 92 : 오류 : 호환 타입
#include <stdio.h>
#include <pthread.h>
#include <time.h>
#include <stdlib.h>
typedef struct pr_struct{
int owner;
int burst_time;
struct pr_struct *next_prcmd;
} prcmd_t;
static prcmd_t *pr_head = NULL;
static prcmd_t *pr_tail = NULL;
static int pending_request = 0;
static pthread_mutex_t prmutex = PTHREAD_MUTEX_INITIALIZER;
int add_queue(prcmd_t *node)
{ pthread_mutex_lock(&prmutex);
//code
prcmd_t *curNode = pr_head;
if(pr_head == NULL) { pr_head = node; return;}
while(curNode->next_prcmd)
{
curNode = curNode->next_prcmd;
}
curNode->next_prcmd = node;
//
pending_request++;
pthread_mutex_unlock(&prmutex);
return(0);
}
**//inprogress
int remove_queue(prcmd_t **node)
{
printf("prenull");
pthread_mutex_lock(&prmutex);
prcmd_t *tempNode;
if(node == NULL)
{
//your code
printf("Queue is empty");
//
pthread_mutex_unlock(&prmutex);
return(-1);
}
else
{
printf("in else");
//your code
tempNode =(*node)->next_prcmd;
free(node);
//
pending_request--;
pthread_mutex_unlock(&prmutex);
return(0);
}
}
//end progress**
int main()
{
if (pr_head == NULL)
{
printf("List is empty!\n\n");
}
int i=0;
int length = 4;
prcmd_t *pr[length];
for(i =0;i<length;i++)
{
pr[i] = (prcmd_t*)malloc(sizeof(prcmd_t));
pr[i]->owner = i+1;
pr[i]->burst_time = i + 2;
add_queue(pr[i]);
}
prcmd_t *curNode = pr_head;
while(curNode)
{
printf("%i %i\n", curNode->owner,curNode->burst_time);
curNode = curNode->next_prcmd;
}
**//something is messed up here i think.
curNode = *pr_head;
remove_queue(&curNode);
//**
while(curNode)
{
printf("%i %i\n", curNode->owner,curNode->burst_time);
curNode = curNode->next_prcmd;
}
}