typedef struct Oft{
int mode;
int refCount;
} OFT;
typedef struct proc{
struct proc *next;
int uss, usp;
int pid; // add pid for identify the proc
int status; // status = FREE|READY|RUNNING|SLEEP|ZOMBIE
int ppid; // parent pid
OFT *fd[10];
int kstack[1024]; // per proc stack area
}PROC;
How would I initialize and use my *fd[10] variable?
assume that I have
PROC *p;
Is this the correct way to initialize its *fd[10]?
for(i = 0; i < 10; i++)
{
p->fd[i] = (OFT *) malloc (sizeof(OFT));
(*p->fd)[0] = Some OFT object?
}
why is p->fd[i] always equal to null when I do the following checking?
if (p->fd[i] == NULL)
//Do sometiong
pfirst before you initialize its members. Also check the return value ofmalloc.