Re: Pointer corruption errors...



First off, thanks for your reply. A lot of the stuff that you noted as errors were things I had put in there 
to test if it was some sort of memory issue I was missing. The reason I'm using readdir, instead of getdents 
and stat, is because I had this problem in a previous attempt at this function which used getdents and stat, 
and I wanted to try a different approach. As it stands now, the function is:

GtkWidget
*recurse_dir2(gchar *path) {
        GtkWidget *tree, *root;
        DIR *dir;
        struct dirent *dirent;

        tree = gtk_tree_new();
        root = gtk_tree_item_new_with_label(path);
        gtk_tree_append(GTK_TREE(tree), root);
        if (!(dir = opendir(path)))
                return 0;
        while ((dirent = readdir(dir)) != NULL)
        {
                if (dirent->d_type == DT_DIR && *dirent->d_name != '.')
                {
                        return 1;
                }
                dirent = (struct dirent *)((unsigned int)dirent+dirent->d_reclen
);
        }

        return tree;

}

The only real change is just the absence of the mallocs, but the pointer corruption still occurs. *root is 
0x8089800 after gtk_tree_item_new_with_label(), 0x8089780 after gtk_tree_append(), and 0x805f4e0 after if 
(!(dir = opendir(path)))

This is starting to seem erratic enough that I'm beginning to think that it isn't a result of poor coding. :)

Thanks
Craig




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