Sunday 15 March 2015

c - struct recursive memory handling issues -


I have created a binary search tree for my program. This is my code:

  Structure node {int steps; Int x; Int y; Structure node * left; Structure node * correct; } * Head; Typedef configuration node * node; Create nodeStep binarytree (node ​​head, int newtpsInt, int x, int y) {if (head == faucet) {head = (node) molec (node)); If (head == faucet) {return tap; } And (head-> step = new phase; head-> x = x; head-> y = y; head-gt; left = head-> right = NULL;}} and {if ( Head-> step & gt; new steps); {head-> left = create stop binary (head-> left, new phase, x, y);} Else {head-> right = createStepsBinaryTree (head -> true, new steps, x, y);}} return head;} ​​  

In this way I call this function with another recursive function: StepsTree = createStepsBinaryTree (stepsTree, steps, x, and so on) [

  Coor insertDataToTree (node ​​steps, curve root, int x, int y, int map [length] [length], int phase) Y);.   

And it is that I am entering that recursive function:

  steps of the node tree = faucet; root = InsertDataToTree (stepsTree, root, startpoint.x, startpoint.y, map, startpoint.steps); now I'm doing the main issue: it runs the first two runs, but then it's the third time in that tree Runs through strands, but when it should give yourself a null straight, which gives something which is close to the tap. This (node ​​*) shows 0x000000000000000000001.  

Does anyone know how can I stop this madness? :)

As @WildPlace noted, you are allocating enough space for a node Type which is an indicator. You either need to change your code so that the node allocates a straight or size (structure node) bytes to your mall.

I strongly suggest that you do not hide your pointer in Tidefef - it is one of many instances that causes problems.

No comments:

Post a Comment