I'm having some trouble while working with pointers in C. It´s been a long time that I don´t use it so my head is a mess right now.
Function "newstage" creates a stage (just a struct) and it passes for "addintopollingtable". This function will just get the pointers and start to build a linked list.
I'm receiving "assignment from incompatible pointer type" in "(*currentStage)->next=s;" but I don´t know if this is the only problem.
First stage that I build must be pointed by "firstStage", the others must be pointed in "next".
"newstage" will be called many times..
stage_t * firstStage = NULL;
stage_t * currentStage = NULL;
int stagesCount = -1;
static void addintopollingtable (stage_t * s) {
stagesCount++;
// First stage
if (firstStage == NULL)
{
firstStage = s;
currentStage = s;
return;
}
(*currentStage)->next=s;
currentStage = s;
}
static int newstage() {
stage_t * stage=NULL;
(*stage)=malloc(sizeof(struct lstage_Stage));
(*stage)->instances=lstage_lfqueue_new();
...
addintopollingtable(stage);
return 1;
}
My stage_t:
typedef struct lstage_Stage * stage_t;
struct lstage_Stage {
LFqueue_t instances;
LFqueue_t event_queue;
Pqueue_t ready_queue;
pool_t pool;
int init_time;
int processed;
int enabled;
char * env;
size_t env_len;
volatile unsigned int flags;
volatile int priority;
stage_t parent;
stage_t next;
int lock;
};
Thank you very much! =)