commit - f054b67ad04873dfbc5d2644a77c3cf422af3c67
commit + e336e3d63c90ab23959397503067ff6a47c38bfc
blob - a3873c07d34fa1c0650467bb32c20c84b15835ce
blob + 18b5c4e7639e1c831115474111a7cfa17e5a9924
--- lib/object_idset.c
+++ lib/object_idset.c
#endif
struct got_object_idset_element {
- RBT_ENTRY(got_object_idset_element) entry;
+ RB_ENTRY(got_object_idset_element) entry;
struct got_object_id id;
void *data; /* API user data */
};
-RBT_HEAD(got_object_idset_tree, got_object_idset_element);
+RB_HEAD(got_object_idset_tree, got_object_idset_element);
static int
cmp_elements(const struct got_object_idset_element *e1,
return got_object_id_cmp(&e1->id, &e2->id);
}
-RBT_PROTOTYPE(got_object_idset_tree, got_object_idset_element, entry,
+RB_PROTOTYPE(got_object_idset_tree, got_object_idset_element, entry,
cmp_elements);
struct got_object_idset {
if (set == NULL)
return NULL;
- RBT_INIT(got_object_idset_tree, &set->entries);
+ RB_INIT(&set->entries);
set->totelem = 0;
return set;
{
struct got_object_idset_element *entry;
- while ((entry = RBT_MIN(got_object_idset_tree, &set->entries))) {
- RBT_REMOVE(got_object_idset_tree, &set->entries, entry);
+ while ((entry = RB_MIN(got_object_idset_tree, &set->entries))) {
+ RB_REMOVE(got_object_idset_tree, &set->entries, entry);
/* User data should be freed by caller. */
free(entry);
}
memcpy(&new->id, id, sizeof(new->id));
new->data = data;
- RBT_INSERT(got_object_idset_tree, &set->entries, new);
+ RB_INSERT(got_object_idset_tree, &set->entries, new);
set->totelem++;
return NULL;
}
{
struct got_object_idset_element *entry;
- entry = RBT_ROOT(got_object_idset_tree, &set->entries);
+ entry = RB_ROOT(&set->entries);
while (entry) {
int cmp = got_object_id_cmp(id, &entry->id);
if (cmp < 0)
- entry = RBT_LEFT(got_object_idset_tree, entry);
+ entry = RB_LEFT(entry, entry);
else if (cmp > 0)
- entry = RBT_RIGHT(got_object_idset_tree, entry);
+ entry = RB_RIGHT(entry, entry);
else
break;
}
return got_error(GOT_ERR_NO_OBJ);
if (id == NULL)
- entry = RBT_ROOT(got_object_idset_tree, &set->entries);
+ entry = RB_ROOT(&set->entries);
else
entry = find_element(set, id);
if (entry == NULL)
return got_error(GOT_ERR_NO_OBJ);
- RBT_REMOVE(got_object_idset_tree, &set->entries, entry);
+ RB_REMOVE(got_object_idset_tree, &set->entries, entry);
if (data)
*data = entry->data;
free(entry);
{
struct got_object_idset_element *entry;
- RBT_FOREACH(entry, got_object_idset_tree, &set->entries)
+ RB_FOREACH(entry, got_object_idset_tree, &set->entries)
(*cb)(&entry->id, entry->data, arg);
}
return set->totelem;
}
-RBT_GENERATE(got_object_idset_tree, got_object_idset_element, entry,
+RB_GENERATE(got_object_idset_tree, got_object_idset_element, entry,
cmp_elements);