cregit-Linux how code gets into the kernel

Release 4.10 tools/perf/util/rblist.c

Directory: tools/perf/util
/*
 * Based on strlist.c by:
 * (c) 2009 Arnaldo Carvalho de Melo <acme@redhat.com>
 *
 * Licensed under the GPLv2.
 */

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

#include "rblist.h"


int rblist__add_node(struct rblist *rblist, const void *new_entry) { struct rb_node **p = &rblist->entries.rb_node; struct rb_node *parent = NULL, *new_node; while (*p != NULL) { int rc; parent = *p; rc = rblist->node_cmp(parent, new_entry); if (rc > 0) p = &(*p)->rb_left; else if (rc < 0) p = &(*p)->rb_right; else return -EEXIST; } new_node = rblist->node_new(rblist, new_entry); if (new_node == NULL) return -ENOMEM; rb_link_node(new_node, parent, p); rb_insert_color(new_node, &rblist->entries); ++rblist->nr_entries; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern152100.00%1100.00%
Total152100.00%1100.00%


void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node) { rb_erase(rb_node, &rblist->entries); --rblist->nr_entries; rblist->node_delete(rblist, rb_node); }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern3487.18%150.00%
suzuki k poulosesuzuki k poulose512.82%150.00%
Total39100.00%2100.00%


static struct rb_node *__rblist__findnew(struct rblist *rblist, const void *entry, bool create) { struct rb_node **p = &rblist->entries.rb_node; struct rb_node *parent = NULL, *new_node = NULL; while (*p != NULL) { int rc; parent = *p; rc = rblist->node_cmp(parent, entry); if (rc > 0) p = &(*p)->rb_left; else if (rc < 0) p = &(*p)->rb_right; else return parent; } if (create) { new_node = rblist->node_new(rblist, entry); if (new_node) { rb_link_node(new_node, parent, p); rb_insert_color(new_node, &rblist->entries); ++rblist->nr_entries; } } return new_node; }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern161100.00%2100.00%
Total161100.00%2100.00%


struct rb_node *rblist__find(struct rblist *rblist, const void *entry) { return __rblist__findnew(rblist, entry, false); }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern27100.00%1100.00%
Total27100.00%1100.00%


struct rb_node *rblist__findnew(struct rblist *rblist, const void *entry) { return __rblist__findnew(rblist, entry, true); }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern27100.00%2100.00%
Total27100.00%2100.00%


void rblist__init(struct rblist *rblist) { if (rblist != NULL) { rblist->entries = RB_ROOT; rblist->nr_entries = 0; } return; }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern31100.00%1100.00%
Total31100.00%1100.00%


void rblist__delete(struct rblist *rblist) { if (rblist != NULL) { struct rb_node *pos, *next = rb_first(&rblist->entries); while (next) { pos = next; next = rb_next(pos); rblist__remove_node(rblist, pos); } free(rblist); } }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern6298.41%150.00%
suzuki k poulosesuzuki k poulose11.59%150.00%
Total63100.00%2100.00%


struct rb_node *rblist__entry(const struct rblist *rblist, unsigned int idx) { struct rb_node *node; for (node = rb_first(&rblist->entries); node; node = rb_next(node)) { if (!idx--) return node; } return NULL; }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern57100.00%1100.00%
Total57100.00%1100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern56498.95%266.67%
suzuki k poulosesuzuki k poulose61.05%133.33%
Total570100.00%3100.00%
Directory: tools/perf/util
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.