~ubuntu-branches/debian/experimental/linux-tools/experimental

« back to all changes in this revision

Viewing changes to tools/perf/util/rblist.c

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2014-02-02 16:57:49 UTC
  • mfrom: (1.1.10) (0.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20140202165749-tw94o9t1t0a8txk6
Tags: 3.13-1~exp2
Merge changes from sid up to 3.12.6-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        rblist->node_delete(rblist, rb_node);
49
49
}
50
50
 
51
 
struct rb_node *rblist__find(struct rblist *rblist, const void *entry)
 
51
static struct rb_node *__rblist__findnew(struct rblist *rblist,
 
52
                                         const void *entry,
 
53
                                         bool create)
52
54
{
53
55
        struct rb_node **p = &rblist->entries.rb_node;
54
 
        struct rb_node *parent = NULL;
 
56
        struct rb_node *parent = NULL, *new_node = NULL;
55
57
 
56
58
        while (*p != NULL) {
57
59
                int rc;
67
69
                        return parent;
68
70
        }
69
71
 
70
 
        return NULL;
 
72
        if (create) {
 
73
                new_node = rblist->node_new(rblist, entry);
 
74
                if (new_node) {
 
75
                        rb_link_node(new_node, parent, p);
 
76
                        rb_insert_color(new_node, &rblist->entries);
 
77
                        ++rblist->nr_entries;
 
78
                }
 
79
        }
 
80
 
 
81
        return new_node;
 
82
}
 
83
 
 
84
struct rb_node *rblist__find(struct rblist *rblist, const void *entry)
 
85
{
 
86
        return __rblist__findnew(rblist, entry, false);
 
87
}
 
88
 
 
89
struct rb_node *rblist__findnew(struct rblist *rblist, const void *entry)
 
90
{
 
91
        return __rblist__findnew(rblist, entry, true);
71
92
}
72
93
 
73
94
void rblist__init(struct rblist *rblist)