anything wrong with this?

From: atv (atv-nospam_at_xs4all.nl)
Date: 12/13/03


Date: Sat, 13 Dec 2003 21:46:38 +0100

Hi,
is there something wrong with this code? It seems that it crashes
at the else { clause, when allocating a second record. Excuse for
the indentation, the g_warnings are from gtk.

Also, i'm using 2 pointers in the struct, which consists of 3 ints,
and 2 pointers, which i give 256 bytes each. Much to much ofcourse,
but it's just testcode.

The code doesn't even reach the g_warning in the { code.
Any help most appreciated.
atv

if(tail==NULL) {
        g_warning("First record in schedule allocated");
        tail=(schedule *)malloc(256);
        tail->string=malloc(256);
        tail->timestamp=malloc(256);
        strcpy(tail->string,string);
        strcpy(tail->timestamp,asctime(tstruct));
        tail->year=tstruct->tm_year;
        tail->month=tstruct->tm_mon;
        tail->day=tstruct->tm_mday;
        tail->next=NULL;
        head=tail;
        } else {
        g_warning("New record in schedule allocated");
        /* First check if a day is already booked */
        while(tmp!=NULL) {
        g_warning("Checking for double appointment");
        if(!strcmp(tmp->timestamp,asctime(tstruct))) {
        gtk_widget_hide(window1);
        return -1;}
        tmp=tmp->next;
        }
        tail->next=(schedule *)malloc(256);
        tail=tail->next;
        tail->string=malloc(256);
        tail->timestamp=malloc(256);
        strcpy(tail->string,string);
        strcpy(tail->timestamp,asctime(tstruct));
        tail->year=tstruct->tm_year;
        tail->month=tstruct->tm_mon;
        tail->day=tstruct->tm_mday;
        tail->next=NULL;