Off Topic - C pointer problems



Ok, not much to do with GTK apart from it is happening within my GTK code!
Before I destroy my PC, I thought I would ask you lot!

I had this:

struct clist_holder {
  otherstruct *sd;
}

struct otherstruct {
  gpointer sd; // this pointer points to the top level of "otherstruct"
}

Somewhere I used g_new one both of them and this line worked fine:

clist_holder->sd=otherstruct->sd; // don't ask!

which did exactly what I wanted. I need something a bit more advanced so I
changed one of the structs to this:

struct clist_holder {
  otherstruct **sd;
  int *mid;
}

So instead I did:

clist_holder->sd[0]=otherstruct->sd;

And now it seg faults on that line! It does this running on Solaris 2.6 with
GTK 1.2.10 and GCC 2.95.2/GCC 3.0 (checked to see if it was a compiler
issue).

HELP!!!!

Rich




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]