Re: question on g_list_insert_sorted () usage



Hello Aarem,

On Thu, Jun 22, 2006 at 05:00:50PM -0500, Aar Em wrote:
> Glist *headers;
> .....
>    headers = g_list_insert_sorted (headers, m,compare_ctime);

Do you initialize headers with NULL? If not, this could be the reason.
Otherwise, use gdb to see where it crashes.


> typedef struct _message_info
> {
>  char *from;
>  char *subject;
>  char *face;
>  long *ctime;
> } MESSAGE_INFO;
...
> 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);
> }

I don't know what long *ctime is, but sorting by pointer value looks
suspicious. This shouldn't segfault, but I'm not sure it does what you
want.


With kind regards,
Baurzhan.



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