integer in struct equals zero later.
Code:
/*
* Instruction_t - stores a specific instruction
*/
typedef struct
{
/*
* action - CPU or IO
*/
Action_t action;
/*
* burstTime - the time taken in the instruction.
*/
int burstTime;
} Instruction_t;
static void loadInstruction( Action_t actionType, int burstTime, PA_t *pa)
{
Instruction_t *instruction;
instruction = (Instruction_t *)malloc( sizeof( Instruction_t));
instruction->action = actionType;
instruction->burstTime = burstTime;
insertLastElement( pa->instructions, (void *)instruction);
}
/* Here pa->instructions is a Linked List, and insertLastElement is defined elsewhere. */
I have a problem. When I run my program (which contains this), through gdb, I can see that burstTime does have a value ( such as 1, 3, 15, etc).
But when I dequeue from my list, instruction->burstTime suddenly equals zero!
Is there something I'm not understanding? Or isn't it anything to do with this part of the code?