anything wrong with this?

From: atv (
Date: 12/13/03

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

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.

if(tail==NULL) {
        g_warning("First record in schedule allocated");
        tail=(schedule *)malloc(256);
        } 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))) {
        return -1;}
        tail->next=(schedule *)malloc(256);

Relevant Pages

  • Re: Good C programming style
    ... > I'm thinking about a good programming style, pros and cons of some topics. ... this has nothing to do with indentation... ... > - function variables: they're used to java, so no pointers. ...
  • Re: Debian Linux on a mac?
    ... so please excuse me jumping in here. ... Any pointers welcome -- I'm in the process of reading the Debian ... Mac install instructions, but pointers always welcome. ...
  • Re: no compile error, but cant run
    ... > I compiled this program without error or warning, ... Not surprising considering that you forgot about proper indentation. ... it wouldn't hurt to have those pointers in the vector actually ...
    ... pointers at all. ... I'll try as an excuse that I had already ranted enough on ... Richard Maine ... domain: summer-triangle ...
  • Re: Subtracting pointers: Which type to use to store the result?
    ... Assume I have two pointers p1 and p2, which both point to a memory ... assumption, I still think it was the OP's intention, due to the phrasing. ... But that's no excuse. ...