amitkindre
amitkindre

Reputation: 43

Not able to debug code in Eclipse linux Error cant find source malloc.c

I am using ECLIPSE IDE on ubuntu I have written simple code to create tree head. Code is getting compiled successfully. But while debugging it give an error when ever it executes malloc statement.

Error

Can't find a source file at "/build/buildd/glibc-2.19/malloc/malloc.c" Locate the file or edit the source lookup path to include its location.

    /*
 * tree.c

 *
 *  Created on: 04-Dec-2014
 *      Author: etron
 */

#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
struct node
{
    int key_value;
    struct node *right;
    struct node *left;
};
struct node *root=0;

struct node* insert(int key,struct node **leaf)
{
    if(*leaf == 0)
    {
        *leaf = (struct node*) malloc(sizeof(struct node));
        (*leaf)->key_value = key;
        (*leaf)->left = 0;
        (*leaf)->right = 0;
        return 0;
    }
}


void  main()
{
    struct node *bt=0;
    int i=100;


    insert(i,&bt);

}

Upvotes: 1

Views: 2153

Answers (1)

Armali
Armali

Reputation: 19375

There's little to be gained from debugging into malloc. Just don't try to step into malloc. Your main is wrong. int main(void). And don't cast the return value of malloc. Enable and heed compiler warnings. It will complain about you not returning from insert. malloc is declared by stdlib.h. Why include malloc.h? – David Heffernan

Thank you Sir It worked with step Over Run – user1551103

Upvotes: 2

Related Questions