c - 'Empty tree' function causing program to crash -
i have empty_tree() function returns true value if tree empty , returns false if not.
bool empty_tree(avl self) { if (self == null) { return true; } else { return false; } }
it exists program easier understand without comments. now, works fine everywhere else in program. when try , use in insert function in place of working:
if(self == null)
my program crash. isn't big deal , using 'if (self==null) suffice, wondering if had ideas why cause program crash. said, it's not extremely important won't bother including more code, if had guesses, i'd appreciate hearing thoughts.
edit: upon request, here's section works:
if (self == null) { self = (avl)malloc(sizeof(struct avlnode)); self->student_id = id; self->left = self->right = null; }
and here's code will, when changed this, crash program:
if (!empty_tree(self)) { self = (avl)malloc(sizeof(struct avlnode)); self->student_id = id; self->left = self->right = null; }
Comments
Post a Comment