question on g_list_insert_sorted () usage



Dear peers,

After struggling with this for over a day, I wanted to ask you for your help regarding usage for g_list_insert_sorted. Can someone please help. Here are the operative parts of my program:

I have the following struct:

typedef struct _message_info
{
 char *from;
 char *subject;
 char *face;
 long *ctime;
} MESSAGE_INFO;

I have the following comparison function:

static gint compare_ctime (gconstpointer a, gconstpointer b)
{
 const MESSAGE_INFO *p1=a,*p2=b;

 return ((p1->ctime > p2->ctime) ? +1: (p1->ctime == p2->ctime) ? 0 : -1);
}

and the following calling part:

Glist *headers;
.....
   MESSAGE_INFO *m;
   m = g_new(MESSAGE_INFO,1);
   m->from = safe_strdup (from);
   m->subject = safe_strdup (subject);
   m->face = safe_strdup (xface);
   m->ctime = ctime;
   headers = g_list_insert_sorted (headers, m,compare_ctime);
....

I get segmentation fault with this, and was wondering how I could fix it. I guess my question is how to use g_list_insert_sorted.

I have Googled quite a bit on this, but have not been able to devise the fix. Any help would be very appreciated. Any suggestions?

Many thanks and best wishes,
Aarem

_________________________________________________________________
Don?t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/




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