Changeset d320b63 for tools


Ignore:
Timestamp:
04/07/06 12:02:52 (16 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
3c81b4e
Parents:
9231fe5
Message:

Fix bug in container while inserting elements into the tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracereport/contain.c

    re3b0188 rd320b63  
     1/* Updated: 2006-04-07 to deal with duplicate inserts */
    12#include <stdio.h>
    23#include <inttypes.h>
     
    45#include <stdlib.h>
    56#include "contain.h"
    6 #include "config.h"
    77
    88splay *splay_search_tree(splay *tree, splay_cmp_t cmp, splay *node) {
    99        splay N, *l, *r, *y;
    1010
    11         if (tree == 0) {
    12                 return 0;
     11        if (tree == NULL) {
     12                return NULL;
    1313        }
    1414
     
    9595        if (tree == NULL) {
    9696                tree = node;
     97                node->left = NULL;
     98                node->right = NULL;
    9799                return tree;
    98100        }
     101        tree=splay_search_tree(tree,cmp,node);
    99102        if (cmp(node,tree)<0) {
    100103                node->left = tree->left;
    101104                node->right = tree;
    102                 tree->left = 0;
     105                tree->left = NULL;
    103106        } else if (cmp(node,tree)>0) {
    104107                node->right = tree->right;
    105108                node->left = tree;
    106                 tree->right = 0;
     109                tree->right = NULL;
    107110        } else {
    108                 free(node);
     111                /* Replace the root node with the current node */
     112                node->left = tree->left;
     113                node->right = tree->right;
     114                free(tree);
     115                tree=node;
    109116        }
    110117
    111         return node;
     118        return tree;
    112119}
    113120
Note: See TracChangeset for help on using the changeset viewer.