help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] segmentation error after compile my program


From: ahmed nasim
Subject: [Help-gsl] segmentation error after compile my program
Date: Sat, 26 Jan 2008 00:47:14 +1100

hello,
i am new linux user. here i am trying to develop program for network intrusion 
detection but after successfully compile getting 1.Segmentation fault (core 
dumped) and 2. pt_insert() failed!. i tried many technique but can't come out 
problem.here i enclosed one function of my program.
please give me feedback 
int
pt_insert(struct pt_context *pt, struct tcp_connection *c)  [header 
function......int  pt_insert(struct pt_context *, struct tcp_connection *);]
{
    struct pt_node *rn = NULL;
    u_char key1[KEY_BYTES], key2[KEY_BYTES];
    int b;

    if (pt->head == NULL)
    {
        /* make a new head node */
        pt->head = pt_new(MIN_KEY_BIT - 1, NULL, NULL, c);
        if (pt->head == NULL)
        {
            perror("pt_insert(): malloc(): ");
            return (0);
        }
        else
        {
            /* increment node counter and return success */
            pt->n++;
            return (1);
        }
    }
    else
    {
        memset(key1, NULL, KEY_BYTES);
        pt_make_key(key1, c);

        switch (pt_search_r(pt->head, key1, &rn))
        {
            case 0:
                memset(key2, NULL, KEY_BYTES);
                pt_make_key(key2, rn->con);

                /* find the first differing bit, and its value */
                rn->bit = diff_bit(key1, key2, &b);

                if (((b ? rn->r : rn->l) == pt_new(MIN_KEY_BIT - 1, NULL, NULL, 
c)) == NULL)
                {
                    return (0);
                }

                if (((b ? rn->l : rn->r) == pt_new(MIN_KEY_BIT - 1, NULL, NULL, 
rn->con)) == NULL)
                {
                    free(b ? rn->r : rn->l);
                    return (0);
                }
                rn->con = NULL;
                /* added two new nodes */
                pt->n += 2;
                return (1);
            case 1:
                return (2);
        }
    }
    return (0);
}
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]