@cryptotaxi247 / netdata-1 / commits / adec24dff

Rename struct avl to avl_element and the typedef to avl_t (#10735)

Before: ``` struct foobar { avl avl; ... } ``` After: ``` struct foobar { avl_t avl; ... }; ``` Which makes figuring out the type from field name easier.

vkalintiris committed Mar 10, 2021 at 10:37 UTC adec24dffa763654bfa8cfa9ae3bd53296c2c24f
29 files changed +136 -136
collectors/apps.plugin/apps_plugin.c
+11 -11
@@ -491,7 +491,7 @@ typedef enum fd_filetype {
491 } FD_FILETYPE;
492
493 struct file_descriptor {
494 - avl avl;
494 + avl_t avl;
495
496 #ifdef NETDATA_INTERNAL_CHECKS
497 uint32_t magic;
@@ -514,7 +514,7 @@ static int
514 // read users and groups from files
515
516 struct user_or_group_id {
517 - avl avl;
517 + avl_t avl;
518
519 union {
520 uid_t uid;
@@ -639,7 +639,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
639 struct user_or_group_id *existing_user_id = NULL;
640
641 if(likely(ids->root))
642 - existing_user_id = (struct user_or_group_id *)avl_search(&ids->index, (avl *) user_or_group_id);
642 + existing_user_id = (struct user_or_group_id *)avl_search(&ids->index, (avl_t *) user_or_group_id);
643
644 if(unlikely(existing_user_id)) {
645 freez(existing_user_id->name);
@@ -648,7 +648,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
648 freez(user_or_group_id);
649 }
650 else {
651 - if(unlikely(avl_insert(&ids->index, (avl *) user_or_group_id) != (void *) user_or_group_id)) {
651 + if(unlikely(avl_insert(&ids->index, (avl_t *) user_or_group_id) != (void *) user_or_group_id)) {
652 error("INTERNAL ERROR: duplicate indexing of id during realloc");
653 };
654
@@ -664,7 +664,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
664
665 while(user_or_group_id) {
666 if(unlikely(!user_or_group_id->updated)) {
667 - if(unlikely((struct user_or_group_id *)avl_remove(&ids->index, (avl *) user_or_group_id) != user_or_group_id))
667 + if(unlikely((struct user_or_group_id *)avl_remove(&ids->index, (avl_t *) user_or_group_id) != user_or_group_id))
668 error("INTERNAL ERROR: removal of unused id from index, removed a different id");
669
670 if(prev_user_id)
@@ -716,7 +716,7 @@ static struct target *get_users_target(uid_t uid) {
716 int ret = read_user_or_group_ids(&all_user_ids, &last_passwd_modification_time);
717
718 if(likely(!ret && all_user_ids.index.root))
719 - user_or_group_id = (struct user_or_group_id *)avl_search(&all_user_ids.index, (avl *) &user_id_to_find);
719 + user_or_group_id = (struct user_or_group_id *)avl_search(&all_user_ids.index, (avl_t *) &user_id_to_find);
720 }
721
722 if(user_or_group_id && user_or_group_id->name && *user_or_group_id->name) {
@@ -764,7 +764,7 @@ struct target *get_groups_target(gid_t gid)
764 int ret = read_user_or_group_ids(&all_group_ids, &last_group_modification_time);
765
766 if(likely(!ret && all_group_ids.index.root))
767 - group_id = (struct user_or_group_id *)avl_search(&all_group_ids.index, (avl *) &group_id_to_find);
767 + group_id = (struct user_or_group_id *)avl_search(&all_group_ids.index, (avl_t *) &group_id_to_find);
768 }
769
770 if(group_id && group_id->name && *group_id->name) {
@@ -1690,7 +1690,7 @@ int file_descriptor_compare(void* a, void* b) {
1690 return strcmp(((struct file_descriptor *)a)->name, ((struct file_descriptor *)b)->name);
1691 }
1692
1693 -// int file_descriptor_iterator(avl *a) { if(a) {}; return 0; }
1693 +// int file_descriptor_iterator(avl_t *a) { if(a) {}; return 0; }
1694
1695 avl_tree_type all_files_index = {
1696 NULL,
@@ -1707,11 +1707,11 @@ static struct file_descriptor *file_descriptor_find(const char *name, uint32_t h
1707 tmp.magic = 0x0BADCAFE;
1708 #endif /* NETDATA_INTERNAL_CHECKS */
1709
1710 - return (struct file_descriptor *)avl_search(&all_files_index, (avl *) &tmp);
1710 + return (struct file_descriptor *)avl_search(&all_files_index, (avl_t *) &tmp);
1711 }
1712
1713 -#define file_descriptor_add(fd) avl_insert(&all_files_index, (avl *)(fd))
1714 -#define file_descriptor_remove(fd) avl_remove(&all_files_index, (avl *)(fd))
1713 +#define file_descriptor_add(fd) avl_insert(&all_files_index, (avl_t *)(fd))
1714 +#define file_descriptor_remove(fd) avl_remove(&all_files_index, (avl_t *)(fd))
1715
1716 // ----------------------------------------------------------------------------
1717
collectors/ebpf.plugin/ebpf_socket.c
+2 -2
@@ -1148,7 +1148,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
1148 memcpy(&test.index, lindex, sizeof(netdata_socket_idx_t));
1149 test.flags = flags;
1150
1151 - ret = (netdata_socket_plot_t *) avl_search_lock(&out->tree, (avl *)&test);
1151 + ret = (netdata_socket_plot_t *) avl_search_lock(&out->tree, (avl_t *)&test);
1152 if (ret) {
1153 if (lvalues->ct > ret->plot.last_time) {
1154 update_socket_data(&ret->sock, lvalues);
@@ -1186,7 +1186,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
1186
1187 w->flags = flags;
1188 netdata_socket_plot_t *check ;
1189 - check = (netdata_socket_plot_t *) avl_insert_lock(&out->tree, (avl *)w);
1189 + check = (netdata_socket_plot_t *) avl_insert_lock(&out->tree, (avl_t *)w);
1190 if (check != w)
1191 error("Internal error, cannot insert the AVL tree.");
1192
collectors/ebpf.plugin/ebpf_socket.h
+1 -1
@@ -232,7 +232,7 @@ typedef struct netdata_socket_idx {
232 */
233 typedef struct netdata_socket_plot {
234 // Search
235 - avl avl;
235 + avl_t avl;
236 netdata_socket_idx_t index;
237
238 // Current data
collectors/statsd.plugin/statsd.c
+3 -3
@@ -107,7 +107,7 @@ typedef enum statsd_metric_type {
107
108
109 typedef struct statsd_metric {
110 - avl avl; // indexing - has to be first
110 + avl_t avl; // indexing - has to be first
111
112 const char *name; // the name of the metric
113 uint32_t hash; // hash of the name
@@ -376,7 +376,7 @@ static inline STATSD_METRIC *statsd_metric_index_find(STATSD_INDEX *index, const
376 tmp.name = name;
377 tmp.hash = (hash)?hash:simple_hash(tmp.name);
378
379 - return (STATSD_METRIC *)STATSD_AVL_SEARCH(&index->index, (avl *)&tmp);
379 + return (STATSD_METRIC *)STATSD_AVL_SEARCH(&index->index, (avl_t *)&tmp);
380 }
381
382 static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, const char *name, STATSD_METRIC_TYPE type) {
@@ -398,7 +398,7 @@ static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, cons
398 m->histogram.ext = callocz(sizeof(STATSD_METRIC_HISTOGRAM_EXTENSIONS), 1);
399 netdata_mutex_init(&m->histogram.ext->mutex);
400 }
401 - STATSD_METRIC *n = (STATSD_METRIC *)STATSD_AVL_INSERT(&index->index, (avl *)m);
401 + STATSD_METRIC *n = (STATSD_METRIC *)STATSD_AVL_INSERT(&index->index, (avl_t *)m);
402 if(unlikely(n != m)) {
403 freez((void *)m->histogram.ext);
404 freez((void *)m->name);
collectors/tc.plugin/plugin_tc.c
+8 -8
@@ -12,7 +12,7 @@
12 #define TC_LINE_MAX 1024
13
14 struct tc_class {
15 - avl avl;
15 + avl_t avl;
16
17 char *id;
18 uint32_t hash;
@@ -56,7 +56,7 @@ struct tc_class {
56 };
57
58 struct tc_device {
59 - avl avl;
59 + avl_t avl;
60
61 char *id;
62 uint32_t hash;
@@ -107,15 +107,15 @@ avl_tree_type tc_device_root_index = {
107 tc_device_compare
108 };
109
110 -#define tc_device_index_add(st) (struct tc_device *)avl_insert(&tc_device_root_index, (avl *)(st))
111 -#define tc_device_index_del(st) (struct tc_device *)avl_remove(&tc_device_root_index, (avl *)(st))
110 +#define tc_device_index_add(st) (struct tc_device *)avl_insert(&tc_device_root_index, (avl_t *)(st))
111 +#define tc_device_index_del(st) (struct tc_device *)avl_remove(&tc_device_root_index, (avl_t *)(st))
112
113 static inline struct tc_device *tc_device_index_find(const char *id, uint32_t hash) {
114 struct tc_device tmp;
115 tmp.id = (char *)id;
116 tmp.hash = (hash)?hash:simple_hash(tmp.id);
117
118 - return (struct tc_device *)avl_search(&(tc_device_root_index), (avl *)&tmp);
118 + return (struct tc_device *)avl_search(&(tc_device_root_index), (avl_t *)&tmp);
119 }
120
121
@@ -128,15 +128,15 @@ static int tc_class_compare(void* a, void* b) {
128 else return strcmp(((struct tc_class *)a)->id, ((struct tc_class *)b)->id);
129 }
130
131 -#define tc_class_index_add(st, rd) (struct tc_class *)avl_insert(&((st)->classes_index), (avl *)(rd))
132 -#define tc_class_index_del(st, rd) (struct tc_class *)avl_remove(&((st)->classes_index), (avl *)(rd))
131 +#define tc_class_index_add(st, rd) (struct tc_class *)avl_insert(&((st)->classes_index), (avl_t *)(rd))
132 +#define tc_class_index_del(st, rd) (struct tc_class *)avl_remove(&((st)->classes_index), (avl_t *)(rd))
133
134 static inline struct tc_class *tc_class_index_find(struct tc_device *st, const char *id, uint32_t hash) {
135 struct tc_class tmp;
136 tmp.id = (char *)id;
137 tmp.hash = (hash)?hash:simple_hash(tmp.id);
138
139 - return (struct tc_class *)avl_search(&(st->classes_index), (avl *) &tmp);
139 + return (struct tc_class *)avl_search(&(st->classes_index), (avl_t *) &tmp);
140 }
141
142 // ----------------------------------------------------------------------------
database/engine/rrdengine.h
+1 -1
@@ -234,4 +234,4 @@ extern void rrdeng_worker(void* arg);
234 extern void rrdeng_enq_cmd(struct rrdengine_worker_config* wc, struct rrdeng_cmd *cmd);
235 extern struct rrdeng_cmd rrdeng_deq_cmd(struct rrdengine_worker_config* wc);
236
237 -#endif /* NETDATA_RRDENGINE_H */
\ No newline at end of file
237 +#endif /* NETDATA_RRDENGINE_H */
database/rrd.h
+7 -7
@@ -130,7 +130,7 @@ extern const char *rrd_algorithm_name(RRD_ALGORITHM algorithm);
130 // RRD FAMILY
131
132 struct rrdfamily {
133 - avl avl;
133 + avl_t avl;
134
135 const char *family;
136 uint32_t hash_family;
@@ -235,7 +235,7 @@ struct rrddim {
235 // ------------------------------------------------------------------------
236 // binary indexing structures
237
238 - avl avl; // the binary index - this has to be first member!
238 + avl_t avl; // the binary index - this has to be first member!
239
240 // ------------------------------------------------------------------------
241 // the dimension definition
@@ -474,8 +474,8 @@ struct rrdset {
474 // ------------------------------------------------------------------------
475 // binary indexing structures
476
477 - avl avl; // the index, with key the id - this has to be first!
478 - avl avlname; // the index, with key the name
477 + avl_t avl; // the index, with key the id - this has to be first!
478 + avl_t avlname; // the index, with key the name
479
480 // ------------------------------------------------------------------------
481 // the set configuration
@@ -727,7 +727,7 @@ struct rrdhost_system_info {
727 };
728
729 struct rrdhost {
730 - avl avl; // the index of hosts
730 + avl_t avl; // the index of hosts
731
732 // ------------------------------------------------------------------------
733 // host information
@@ -1286,8 +1286,8 @@ extern int rrdfamily_compare(void *a, void *b);
1286 extern RRDFAMILY *rrdfamily_create(RRDHOST *host, const char *id);
1287 extern void rrdfamily_free(RRDHOST *host, RRDFAMILY *rc);
1288
1289 -#define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl *)(st))
1290 -#define rrdset_index_del(host, st) (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index), (avl *)(st))
1289 +#define rrdset_index_add(host, st) (RRDSET *)avl_insert_lock(&((host)->rrdset_root_index), (avl_t *)(st))
1290 +#define rrdset_index_del(host, st) (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index), (avl_t *)(st))
1291 extern RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st);
1292
1293 extern void rrdset_free(RRDSET *st);
database/rrdcalc.c
+7 -7
@@ -472,7 +472,7 @@ inline RRDCALC *rrdcalc_create_from_template(RRDHOST *host, RRDCALCTEMPLATE *rt,
472
473 rrdcalc_add_to_host(host, rc);
474 if(!rt->foreachdim) {
475 - RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl *)rc);
475 + RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl_t *)rc);
476 if (rdcmp != rc) {
477 error("Cannot insert the alarm index ID %s",rc->name);
478 }
@@ -605,17 +605,17 @@ void rrdcalc_unlink_and_free(RRDHOST *host, RRDCALC *rc) {
605 error("Cannot unlink alarm '%s.%s' from host '%s': not found", rc->chart?rc->chart:"NOCHART", rc->name, host->hostname);
606 }
607
608 - RRDCALC *rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_health_log, (avl *)rc);
608 + RRDCALC *rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_health_log, (avl_t *)rc);
609 if (rdcmp) {
610 - rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_health_log, (avl *)rc);
610 + rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_health_log, (avl_t *)rc);
611 if (!rdcmp) {
612 error("Cannot remove the health alarm index from health_log");
613 }
614 }
615
616 - rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_name, (avl *)rc);
616 + rdcmp = (RRDCALC *) avl_search_lock(&(host)->alarms_idx_name, (avl_t *)rc);
617 if (rdcmp) {
618 - rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_name, (avl *)rc);
618 + rdcmp = (RRDCALC *) avl_remove_lock(&(host)->alarms_idx_name, (avl_t *)rc);
619 if (!rdcmp) {
620 error("Cannot remove the health alarm index from idx_name");
621 }
@@ -727,7 +727,7 @@ void rrdcalc_labels_unlink() {
727 int alarm_isrepeating(RRDHOST *host, uint32_t alarm_id) {
728 RRDCALC findme;
729 findme.id = alarm_id;
730 - RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_health_log, (avl *)&findme);
730 + RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_health_log, (avl_t *)&findme);
731 if (!rc) {
732 return 0;
733 }
@@ -761,7 +761,7 @@ RRDCALC *alarm_max_last_repeat(RRDHOST *host, char *alarm_name,uint32_t hash) {
761 RRDCALC findme;
762 findme.name = alarm_name;
763 findme.hash = hash;
764 - RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_name, (avl *)&findme);
764 + RRDCALC *rc = (RRDCALC *)avl_search_lock(&host->alarms_idx_name, (avl_t *)&findme);
765
766 return rc;
767 }
database/rrdcalc.h
+1 -1
@@ -32,7 +32,7 @@
32
33
34 struct rrdcalc {
35 - avl avl; // the index, with key the id - this has to be first!
35 + avl_t avl; // the index, with key the id - this has to be first!
36 uint32_t id; // the unique id of this alarm
37 uint32_t next_event_id; // the next event id that will be used for this alarm
38
database/rrddim.c
+5 -5
@@ -38,15 +38,15 @@ int rrddim_compare(void* a, void* b) {
38 else return strcmp(((RRDDIM *)a)->id, ((RRDDIM *)b)->id);
39 }
40
41 -#define rrddim_index_add(st, rd) (RRDDIM *)avl_insert_lock(&((st)->dimensions_index), (avl *)(rd))
42 -#define rrddim_index_del(st,rd ) (RRDDIM *)avl_remove_lock(&((st)->dimensions_index), (avl *)(rd))
41 +#define rrddim_index_add(st, rd) (RRDDIM *)avl_insert_lock(&((st)->dimensions_index), (avl_t *)(rd))
42 +#define rrddim_index_del(st,rd ) (RRDDIM *)avl_remove_lock(&((st)->dimensions_index), (avl_t *)(rd))
43
44 static inline RRDDIM *rrddim_index_find(RRDSET *st, const char *id, uint32_t hash) {
45 RRDDIM tmp = {
46 .id = id,
47 .hash = (hash)?hash:simple_hash(id)
48 };
49 - return (RRDDIM *)avl_search_lock(&(st->dimensions_index), (avl *) &tmp);
49 + return (RRDDIM *)avl_search_lock(&(st->dimensions_index), (avl_t *) &tmp);
50 }
51
52
@@ -197,7 +197,7 @@ void rrdcalc_link_to_rrddim(RRDDIM *rd, RRDSET *st, RRDHOST *host) {
197 RRDCALC *child = rrdcalc_create_from_rrdcalc(rrdc, host, usename, rd->name);
198 if (child) {
199 rrdcalc_add_to_host(host, child);
200 - RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl *)child);
200 + RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_health_log,(avl_t *)child);
201 if (rdcmp != child) {
202 error("Cannot insert the alarm index ID %s",child->name);
203 }
@@ -277,7 +277,7 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte
277 if(likely(rd)) {
278 // we have a file mapped for rd
279
280 - memset(&rd->avl, 0, sizeof(avl));
280 + memset(&rd->avl, 0, sizeof(avl_t));
281 rd->id = NULL;
282 rd->name = NULL;
283 rd->cache_filename = NULL;
database/rrdfamily.c
+3 -3
@@ -12,15 +12,15 @@ int rrdfamily_compare(void *a, void *b) {
12 else return strcmp(((RRDFAMILY *)a)->family, ((RRDFAMILY *)b)->family);
13 }
14
15 -#define rrdfamily_index_add(host, rc) (RRDFAMILY *)avl_insert_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
16 -#define rrdfamily_index_del(host, rc) (RRDFAMILY *)avl_remove_lock(&((host)->rrdfamily_root_index), (avl *)(rc))
15 +#define rrdfamily_index_add(host, rc) (RRDFAMILY *)avl_insert_lock(&((host)->rrdfamily_root_index), (avl_t *)(rc))
16 +#define rrdfamily_index_del(host, rc) (RRDFAMILY *)avl_remove_lock(&((host)->rrdfamily_root_index), (avl_t *)(rc))
17
18 static RRDFAMILY *rrdfamily_index_find(RRDHOST *host, const char *id, uint32_t hash) {
19 RRDFAMILY tmp;
20 tmp.family = id;
21 tmp.hash_family = (hash)?hash:simple_hash(tmp.family);
22
23 - return (RRDFAMILY *)avl_search_lock(&(host->rrdfamily_root_index), (avl *) &tmp);
23 + return (RRDFAMILY *)avl_search_lock(&(host->rrdfamily_root_index), (avl_t *) &tmp);
24 }
25
26 RRDFAMILY *rrdfamily_create(RRDHOST *host, const char *id) {
database/rrdhost.c
+3 -3
@@ -31,7 +31,7 @@ RRDHOST *rrdhost_find_by_guid(const char *guid, uint32_t hash) {
31 strncpyz(tmp.machine_guid, guid, GUID_LEN);
32 tmp.hash_machine_guid = (hash)?hash:simple_hash(tmp.machine_guid);
33
34 - return (RRDHOST *)avl_search_lock(&(rrdhost_root_index), (avl *) &tmp);
34 + return (RRDHOST *)avl_search_lock(&(rrdhost_root_index), (avl_t *) &tmp);
35 }
36
37 RRDHOST *rrdhost_find_by_hostname(const char *hostname, uint32_t hash) {
@@ -53,8 +53,8 @@ RRDHOST *rrdhost_find_by_hostname(const char *hostname, uint32_t hash) {
53 return NULL;
54 }
55
56 -#define rrdhost_index_add(rrdhost) (RRDHOST *)avl_insert_lock(&(rrdhost_root_index), (avl *)(rrdhost))
57 -#define rrdhost_index_del(rrdhost) (RRDHOST *)avl_remove_lock(&(rrdhost_root_index), (avl *)(rrdhost))
56 +#define rrdhost_index_add(rrdhost) (RRDHOST *)avl_insert_lock(&(rrdhost_root_index), (avl_t *)(rrdhost))
57 +#define rrdhost_index_del(rrdhost) (RRDHOST *)avl_remove_lock(&(rrdhost_root_index), (avl_t *)(rrdhost))
58
59
60 // ----------------------------------------------------------------------------
database/rrdset.c
+6 -6
@@ -35,7 +35,7 @@ static RRDSET *rrdset_index_find(RRDHOST *host, const char *id, uint32_t hash) {
35 strncpyz(tmp.id, id, RRD_ID_LENGTH_MAX);
36 tmp.hash = (hash)?hash:simple_hash(tmp.id);
37
38 - return (RRDSET *)avl_search_lock(&(host->rrdset_root_index), (avl *) &tmp);
38 + return (RRDSET *)avl_search_lock(&(host->rrdset_root_index), (avl_t *) &tmp);
39 }
40
41 // ----------------------------------------------------------------------------
@@ -57,7 +57,7 @@ int rrdset_compare_name(void* a, void* b) {
57 RRDSET *rrdset_index_add_name(RRDHOST *host, RRDSET *st) {
58 void *result;
59 // fprintf(stderr, "ADDING: %s (name: %s)\n", st->id, st->name);
60 - result = avl_insert_lock(&host->rrdset_root_index_name, (avl *) (&st->avlname));
60 + result = avl_insert_lock(&host->rrdset_root_index_name, (avl_t *) (&st->avlname));
61 if(result) return rrdset_from_avlname(result);
62 return NULL;
63 }
@@ -65,7 +65,7 @@ RRDSET *rrdset_index_add_name(RRDHOST *host, RRDSET *st) {
65 RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st) {
66 void *result;
67 // fprintf(stderr, "DELETING: %s (name: %s)\n", st->id, st->name);
68 - result = (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index_name), (avl *)(&st->avlname));
68 + result = (RRDSET *)avl_remove_lock(&((host)->rrdset_root_index_name), (avl_t *)(&st->avlname));
69 if(result) return rrdset_from_avlname(result);
70 return NULL;
71 }
@@ -81,7 +81,7 @@ static inline RRDSET *rrdset_index_find_name(RRDHOST *host, const char *name, ui
81 tmp.hash_name = (hash)?hash:simple_hash(tmp.name);
82
83 // fprintf(stderr, "SEARCHING: %s\n", name);
84 - result = avl_search_lock(&host->rrdset_root_index_name, (avl *) (&(tmp.avlname)));
84 + result = avl_search_lock(&host->rrdset_root_index_name, (avl_t *) (&(tmp.avlname)));
85 if(result) {
86 RRDSET *st = rrdset_from_avlname(result);
87 if(strcmp(st->magic, RRDSET_MAGIC) != 0)
@@ -744,8 +744,8 @@ RRDSET *rrdset_create_custom(
744 );
745
746 if(st) {
747 - memset(&st->avl, 0, sizeof(avl));
748 - memset(&st->avlname, 0, sizeof(avl));
747 + memset(&st->avl, 0, sizeof(avl_t));
748 + memset(&st->avlname, 0, sizeof(avl_t));
749 memset(&st->rrdvar_root_index, 0, sizeof(avl_tree_lock));
750 memset(&st->dimensions_index, 0, sizeof(avl_tree_lock));
751 memset(&st->rrdset_rwlock, 0, sizeof(netdata_rwlock_t));
database/rrdvar.c
+3 -3
@@ -27,7 +27,7 @@ int rrdvar_compare(void* a, void* b) {
27 }
28
29 static inline RRDVAR *rrdvar_index_add(avl_tree_lock *tree, RRDVAR *rv) {
30 - RRDVAR *ret = (RRDVAR *)avl_insert_lock(tree, (avl *)(rv));
30 + RRDVAR *ret = (RRDVAR *)avl_insert_lock(tree, (avl_t *)(rv));
31 if(ret != rv)
32 debug(D_VARIABLES, "Request to insert RRDVAR '%s' into index failed. Already exists.", rv->name);
33
@@ -35,7 +35,7 @@ static inline RRDVAR *rrdvar_index_add(avl_tree_lock *tree, RRDVAR *rv) {
35 }
36
37 static inline RRDVAR *rrdvar_index_del(avl_tree_lock *tree, RRDVAR *rv) {
38 - RRDVAR *ret = (RRDVAR *)avl_remove_lock(tree, (avl *)(rv));
38 + RRDVAR *ret = (RRDVAR *)avl_remove_lock(tree, (avl_t *)(rv));
39 if(!ret)
40 error("Request to remove RRDVAR '%s' from index failed. Not Found.", rv->name);
41
@@ -47,7 +47,7 @@ static inline RRDVAR *rrdvar_index_find(avl_tree_lock *tree, const char *name, u
47 tmp.name = (char *)name;
48 tmp.hash = (hash)?hash:simple_hash(tmp.name);
49
50 - return (RRDVAR *)avl_search_lock(tree, (avl *)&tmp);
50 + return (RRDVAR *)avl_search_lock(tree, (avl_t *)&tmp);
51 }
52
53 inline void rrdvar_free(RRDHOST *host, avl_tree_lock *tree, RRDVAR *rv) {
database/rrdvar.h
+1 -1
@@ -32,7 +32,7 @@ typedef enum rrdvar_options {
32 // 2. at each context (RRDFAMILY.rrdvar_root_index)
33 // 3. at each host (RRDHOST.rrdvar_root_index)
34 struct rrdvar {
35 - avl avl;
35 + avl_t avl;
36
37 char *name;
38 uint32_t hash;
health/health_log.c
+1 -1
@@ -243,7 +243,7 @@ static inline ssize_t health_alarm_log_read(RRDHOST *host, FILE *fp, const char
243 RRDCALC *rc = alarm_max_last_repeat(host, alarm_name,simple_hash(alarm_name));
244 if (!rc) {
245 for(rc = host->alarms; rc ; rc = rc->next) {
246 - RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_name, (avl *)rc);
246 + RRDCALC *rdcmp = (RRDCALC *) avl_insert_lock(&(host)->alarms_idx_name, (avl_t *)rc);
247 if(rdcmp != rc) {
248 error("Cannot insert the alarm index ID using log %s", rc->name);
249 }
libnetdata/avl/avl.c
+28 -28
@@ -17,8 +17,8 @@
17
18 /* Search |tree| for an item matching |item|, and return it if found.
19 Otherwise return |NULL|. */
20 -avl *avl_search(avl_tree_type *tree, avl *item) {
21 - avl *p;
20 +avl_t *avl_search(avl_tree_type *tree, avl_t *item) {
21 + avl_t *p;
22
23 // assert (tree != NULL && item != NULL);
24
@@ -40,11 +40,11 @@ avl *avl_search(avl_tree_type *tree, avl *item) {
40 If a duplicate item is found in the tree,
41 returns a pointer to the duplicate without inserting |item|.
42 */
43 -avl *avl_insert(avl_tree_type *tree, avl *item) {
44 - avl *y, *z; /* Top node to update balance factor, and parent. */
45 - avl *p, *q; /* Iterator, and parent. */
46 - avl *n; /* Newly inserted node. */
47 - avl *w; /* New root of rebalanced subtree. */
43 +avl_t *avl_insert(avl_tree_type *tree, avl_t *item) {
44 + avl_t *y, *z; /* Top node to update balance factor, and parent. */
45 + avl_t *p, *q; /* Iterator, and parent. */
46 + avl_t *n; /* Newly inserted node. */
47 + avl_t *w; /* New root of rebalanced subtree. */
48 unsigned char dir; /* Direction to descend. */
49
50 unsigned char da[AVL_MAX_HEIGHT]; /* Cached comparison results. */
@@ -52,7 +52,7 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
52
53 // assert(tree != NULL && item != NULL);
54
55 - z = (avl *) &tree->root;
55 + z = (avl_t *) &tree->root;
56 y = tree->root;
57 dir = 0;
58 for (q = z, p = y; p != NULL; q = p, p = p->avl_link[dir]) {
@@ -79,7 +79,7 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
79 p->avl_balance++;
80
81 if (y->avl_balance == -2) {
82 - avl *x = y->avl_link[0];
82 + avl_t *x = y->avl_link[0];
83 if (x->avl_balance == -1) {
84 w = x;
85 y->avl_link[0] = x->avl_link[1];
@@ -103,7 +103,7 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
103 }
104 }
105 else if (y->avl_balance == +2) {
106 - avl *x = y->avl_link[1];
106 + avl_t *x = y->avl_link[1];
107 if (x->avl_balance == +1) {
108 w = x;
109 y->avl_link[1] = x->avl_link[0];
@@ -136,19 +136,19 @@ avl *avl_insert(avl_tree_type *tree, avl *item) {
136
137 /* Deletes from |tree| and returns an item matching |item|.
138 Returns a null pointer if no matching item found. */
139 -avl *avl_remove(avl_tree_type *tree, avl *item) {
139 +avl_t *avl_remove(avl_tree_type *tree, avl_t *item) {
140 /* Stack of nodes. */
141 - avl *pa[AVL_MAX_HEIGHT]; /* Nodes. */
141 + avl_t *pa[AVL_MAX_HEIGHT]; /* Nodes. */
142 unsigned char da[AVL_MAX_HEIGHT]; /* |avl_link[]| indexes. */
143 int k; /* Stack pointer. */
144
145 - avl *p; /* Traverses tree to find node to delete. */
145 + avl_t *p; /* Traverses tree to find node to delete. */
146 int cmp; /* Result of comparison between |item| and |p|. */
147
148 // assert (tree != NULL && item != NULL);
149
150 k = 0;
151 - p = (avl *) &tree->root;
151 + p = (avl_t *) &tree->root;
152 for(cmp = -1; cmp != 0; cmp = tree->compar(item, p)) {
153 unsigned char dir = (unsigned char)(cmp > 0);
154
@@ -164,7 +164,7 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
164 if (p->avl_link[1] == NULL)
165 pa[k - 1]->avl_link[da[k - 1]] = p->avl_link[0];
166 else {
167 - avl *r = p->avl_link[1];
167 + avl_t *r = p->avl_link[1];
168 if (r->avl_link[0] == NULL) {
169 r->avl_link[0] = p->avl_link[0];
170 r->avl_balance = p->avl_balance;
@@ -173,7 +173,7 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
173 pa[k++] = r;
174 }
175 else {
176 - avl *s;
176 + avl_t *s;
177 int j = k++;
178
179 for (;;) {
@@ -198,15 +198,15 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
198
199 // assert (k > 0);
200 while (--k > 0) {
201 - avl *y = pa[k];
201 + avl_t *y = pa[k];
202
203 if (da[k] == 0) {
204 y->avl_balance++;
205 if (y->avl_balance == +1) break;
206 else if (y->avl_balance == +2) {
207 - avl *x = y->avl_link[1];
207 + avl_t *x = y->avl_link[1];
208 if (x->avl_balance == -1) {
209 - avl *w;
209 + avl_t *w;
210 // assert (x->avl_balance == -1);
211 w = x->avl_link[0];
212 x->avl_link[0] = w->avl_link[1];
@@ -240,9 +240,9 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
240 y->avl_balance--;
241 if (y->avl_balance == -1) break;
242 else if (y->avl_balance == -2) {
243 - avl *x = y->avl_link[0];
243 + avl_t *x = y->avl_link[0];
244 if (x->avl_balance == +1) {
245 - avl *w;
245 + avl_t *w;
246 // assert (x->avl_balance == +1);
247 w = x->avl_link[1];
248 x->avl_link[1] = w->avl_link[0];
@@ -284,7 +284,7 @@ avl *avl_remove(avl_tree_type *tree, avl *item) {
284 // ---------------------------
285 // traversing
286
287 -int avl_walker(avl *node, int (*callback)(void * /*entry*/, void * /*data*/), void *data) {
287 +int avl_walker(avl_t *node, int (*callback)(void * /*entry*/, void * /*data*/), void *data) {
288 int total = 0, ret = 0;
289
290 if(node->avl_link[0]) {
@@ -383,23 +383,23 @@ void avl_destroy_lock(avl_tree_lock *tree) {
383 #endif /* AVL_WITHOUT_PTHREADS */
384 }
385
386 -avl *avl_search_lock(avl_tree_lock *tree, avl *item) {
386 +avl_t *avl_search_lock(avl_tree_lock *tree, avl_t *item) {
387 avl_read_lock(tree);
388 - avl *ret = avl_search(&tree->avl_tree, item);
388 + avl_t *ret = avl_search(&tree->avl_tree, item);
389 avl_unlock(tree);
390 return ret;
391 }
392
393 -avl * avl_remove_lock(avl_tree_lock *tree, avl *item) {
393 +avl_t * avl_remove_lock(avl_tree_lock *tree, avl_t *item) {
394 avl_write_lock(tree);
395 - avl *ret = avl_remove(&tree->avl_tree, item);
395 + avl_t *ret = avl_remove(&tree->avl_tree, item);
396 avl_unlock(tree);
397 return ret;
398 }
399
400 -avl *avl_insert_lock(avl_tree_lock *tree, avl *item) {
400 +avl_t *avl_insert_lock(avl_tree_lock *tree, avl_t *item) {
401 avl_write_lock(tree);
402 - avl * ret = avl_insert(&tree->avl_tree, item);
402 + avl_t * ret = avl_insert(&tree->avl_tree, item);
403 avl_unlock(tree);
404 return ret;
405 }
libnetdata/avl/avl.h
+10 -10
@@ -28,14 +28,14 @@
28 /* Data structures */
29
30 /* One element of the AVL tree */
31 -typedef struct avl {
32 - struct avl *avl_link[2]; /* Subtrees. */
31 +typedef struct avl_element {
32 + struct avl_element *avl_link[2]; /* Subtrees. */
33 signed char avl_balance; /* Balance factor. */
34 -} avl;
34 +} avl_t;
35
36 /* An AVL tree */
37 typedef struct avl_tree_type {
38 - avl *root;
38 + avl_t *root;
39 int (*compar)(void *a, void *b);
40 } avl_tree_type;
41
@@ -59,23 +59,23 @@ typedef struct avl_tree_lock {
59 * a is linked directly to the tree, so it has to
60 * be properly allocated by the caller.
61 */
62 -avl *avl_insert_lock(avl_tree_lock *tree, avl *item) NEVERNULL WARNUNUSED;
63 -avl *avl_insert(avl_tree_type *tree, avl *item) NEVERNULL WARNUNUSED;
62 +avl_t *avl_insert_lock(avl_tree_lock *tree, avl_t *item) NEVERNULL WARNUNUSED;
63 +avl_t *avl_insert(avl_tree_type *tree, avl_t *item) NEVERNULL WARNUNUSED;
64
65 /* Remove an element a from the AVL tree t
66 * returns a pointer to the removed element
67 * or NULL if an element equal to a is not found
68 * (equal as returned by t->compar())
69 */
70 -avl *avl_remove_lock(avl_tree_lock *tree, avl *item) WARNUNUSED;
71 -avl *avl_remove(avl_tree_type *tree, avl *item) WARNUNUSED;
70 +avl_t *avl_remove_lock(avl_tree_lock *tree, avl_t *item) WARNUNUSED;
71 +avl_t *avl_remove(avl_tree_type *tree, avl_t *item) WARNUNUSED;
72
73 /* Find the element into the tree that equal to a
74 * (equal as returned by t->compar())
75 * returns NULL is no element is equal to a
76 */
77 -avl *avl_search_lock(avl_tree_lock *tree, avl *item);
78 -avl *avl_search(avl_tree_type *tree, avl *item);
77 +avl_t *avl_search_lock(avl_tree_lock *tree, avl_t *item);
78 +avl_t *avl_search(avl_tree_type *tree, avl_t *item);
79
80 /* Initialize the avl_tree_lock
81 */
libnetdata/config/appconfig.c
+6 -6
@@ -123,15 +123,15 @@ static int appconfig_option_compare(void *a, void *b) {
123 else return strcmp(((struct config_option *)a)->name, ((struct config_option *)b)->name);
124 }
125
126 -#define appconfig_option_index_add(co, cv) (struct config_option *)avl_insert_lock(&((co)->values_index), (avl *)(cv))
127 -#define appconfig_option_index_del(co, cv) (struct config_option *)avl_remove_lock(&((co)->values_index), (avl *)(cv))
126 +#define appconfig_option_index_add(co, cv) (struct config_option *)avl_insert_lock(&((co)->values_index), (avl_t *)(cv))
127 +#define appconfig_option_index_del(co, cv) (struct config_option *)avl_remove_lock(&((co)->values_index), (avl_t *)(cv))
128
129 static struct config_option *appconfig_option_index_find(struct section *co, const char *name, uint32_t hash) {
130 struct config_option tmp;
131 tmp.hash = (hash)?hash:simple_hash(name);
132 tmp.name = (char *)name;
133
134 - return (struct config_option *)avl_search_lock(&(co->values_index), (avl *) &tmp);
134 + return (struct config_option *)avl_search_lock(&(co->values_index), (avl_t *) &tmp);
135 }
136
137
@@ -144,15 +144,15 @@ int appconfig_section_compare(void *a, void *b) {
144 else return strcmp(((struct section *)a)->name, ((struct section *)b)->name);
145 }
146
147 -#define appconfig_index_add(root, cfg) (struct section *)avl_insert_lock(&(root)->index, (avl *)(cfg))
148 -#define appconfig_index_del(root, cfg) (struct section *)avl_remove_lock(&(root)->index, (avl *)(cfg))
147 +#define appconfig_index_add(root, cfg) (struct section *)avl_insert_lock(&(root)->index, (avl_t *)(cfg))
148 +#define appconfig_index_del(root, cfg) (struct section *)avl_remove_lock(&(root)->index, (avl_t *)(cfg))
149
150 static struct section *appconfig_index_find(struct config *root, const char *name, uint32_t hash) {
151 struct section tmp;
152 tmp.hash = (hash)?hash:simple_hash(name);
153 tmp.name = (char *)name;
154
155 - return (struct section *)avl_search_lock(&root->index, (avl *) &tmp);
155 + return (struct section *)avl_search_lock(&root->index, (avl_t *) &tmp);
156 }
157
158
libnetdata/config/appconfig.h
+2 -2
@@ -111,7 +111,7 @@
111 #define CONFIG_VALUE_CHECKED 0x08 // has been checked if the value is different from the default
112
113 struct config_option {
114 - avl avl_node; // the index entry of this entry - this has to be first!
114 + avl_t avl_node; // the index entry of this entry - this has to be first!
115
116 uint8_t flags;
117 uint32_t hash; // a simple hash to speed up searching
@@ -124,7 +124,7 @@ struct config_option {
124 };
125
126 struct section {
127 - avl avl_node; // the index entry of this section - this has to be first!
127 + avl_t avl_node; // the index entry of this section - this has to be first!
128
129 uint32_t hash; // a simple hash to speed up searching
130 // we first compare hashes, and only if the hashes are equal we do string comparisons
libnetdata/dictionary/dictionary.c
+5 -5
@@ -67,7 +67,7 @@ static inline NAME_VALUE *dictionary_name_value_index_find_nolock(DICTIONARY *di
67 tmp.name = (char *)name;
68
69 NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict);
70 - return (NAME_VALUE *)avl_search(&(dict->values_index), (avl *) &tmp);
70 + return (NAME_VALUE *)avl_search(&(dict->values_index), (avl_t *) &tmp);
71 }
72
73 // ----------------------------------------------------------------------------
@@ -95,7 +95,7 @@ static NAME_VALUE *dictionary_name_value_create_nolock(DICTIONARY *dict, const c
95
96 // index it
97 NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict);
98 - if(unlikely(avl_insert(&((dict)->values_index), (avl *)(nv)) != (avl *)nv))
98 + if(unlikely(avl_insert(&((dict)->values_index), (avl_t *)(nv)) != (avl_t *)nv))
99 error("dictionary: INTERNAL ERROR: duplicate insertion to dictionary.");
100
101 NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict);
@@ -107,7 +107,7 @@ static void dictionary_name_value_destroy_nolock(DICTIONARY *dict, NAME_VALUE *n
107 debug(D_DICTIONARY, "Destroying name value entry for name '%s'.", nv->name);
108
109 NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict);
110 - if(unlikely(avl_remove(&(dict->values_index), (avl *)(nv)) != (avl *)nv))
110 + if(unlikely(avl_remove(&(dict->values_index), (avl_t *)(nv)) != (avl_t *)nv))
111 error("dictionary: INTERNAL ERROR: dictionary invalid removal of node.");
112
113 NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict);
@@ -258,7 +258,7 @@ int dictionary_del(DICTIONARY *dict, const char *name) {
258 // the dictionary is locked for reading while this happens
259 // do not user other dictionary calls while walking the dictionary - deadlock!
260
261 -static int dictionary_walker(avl *a, int (*callback)(void *entry, void *data), void *data) {
261 +static int dictionary_walker(avl_t *a, int (*callback)(void *entry, void *data), void *data) {
262 int total = 0, ret = 0;
263
264 if(a->avl_link[0]) {
@@ -293,7 +293,7 @@ int dictionary_get_all(DICTIONARY *dict, int (*callback)(void *entry, void *data
293 return ret;
294 }
295
296 -static int dictionary_walker_name_value(avl *a, int (*callback)(char *name, void *entry, void *data), void *data) {
296 +static int dictionary_walker_name_value(avl_t *a, int (*callback)(char *name, void *entry, void *data), void *data) {
297 int total = 0, ret = 0;
298
299 if(a->avl_link[0]) {
libnetdata/dictionary/dictionary.h
+1 -1
@@ -13,7 +13,7 @@ struct dictionary_stats {
13 };
14
15 typedef struct name_value {
16 - avl avl_node; // the index - this has to be first!
16 + avl_t avl_node; // the index - this has to be first!
17
18 uint32_t hash; // a simple hash to speed up searching
19 // we first compare hashes, and only if the hashes are equal we do string comparisons
registry/registry_person.c
+2 -2
@@ -32,7 +32,7 @@ inline REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, c
32
33 inline REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) {
34 debug(D_REGISTRY, "Registry: registry_person_url_index_add('%s', '%s')", p->guid, pu->url->url);
35 - REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_insert(&(p->person_urls), (avl *)(pu));
35 + REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_insert(&(p->person_urls), (avl_t *)(pu));
36 if(tpu != pu)
37 error("Registry: registry_person_url_index_add('%s', '%s') already exists as '%s'", p->guid, pu->url->url, tpu->url->url);
38
@@ -41,7 +41,7 @@ inline REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, RE
41
42 inline REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) {
43 debug(D_REGISTRY, "Registry: registry_person_url_index_del('%s', '%s')", p->guid, pu->url->url);
44 - REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_remove(&(p->person_urls), (avl *)(pu));
44 + REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_remove(&(p->person_urls), (avl_t *)(pu));
45 if(!tpu)
46 error("Registry: registry_person_url_index_del('%s', '%s') deleted nothing", p->guid, pu->url->url);
47 else if(tpu != pu)
registry/registry_person.h
+1 -1
@@ -10,7 +10,7 @@
10
11 // for each PERSON-URL pair we keep this
12 struct registry_person_url {
13 - avl avl; // binary tree node
13 + avl_t avl; // binary tree node
14
15 REGISTRY_URL *url; // de-duplicated URL
16 REGISTRY_MACHINE *machine; // link the MACHINE of this URL
registry/registry_url.c
+3 -3
@@ -13,11 +13,11 @@ int registry_url_compare(void *a, void *b) {
13 }
14
15 inline REGISTRY_URL *registry_url_index_add(REGISTRY_URL *u) {
16 - return (REGISTRY_URL *)avl_insert(&(registry.registry_urls_root_index), (avl *)(u));
16 + return (REGISTRY_URL *)avl_insert(&(registry.registry_urls_root_index), (avl_t *)(u));
17 }
18
19 inline REGISTRY_URL *registry_url_index_del(REGISTRY_URL *u) {
20 - return (REGISTRY_URL *)avl_remove(&(registry.registry_urls_root_index), (avl *)(u));
20 + return (REGISTRY_URL *)avl_remove(&(registry.registry_urls_root_index), (avl_t *)(u));
21 }
22
23 REGISTRY_URL *registry_url_get(const char *url, size_t urllen) {
@@ -33,7 +33,7 @@ REGISTRY_URL *registry_url_get(const char *url, size_t urllen) {
33 strncpyz(n->url, url, n->len);
34 n->hash = simple_hash(n->url);
35
36 - REGISTRY_URL *u = (REGISTRY_URL *)avl_search(&(registry.registry_urls_root_index), (avl *)n);
36 + REGISTRY_URL *u = (REGISTRY_URL *)avl_search(&(registry.registry_urls_root_index), (avl_t *)n);
37 if(!u) {
38 debug(D_REGISTRY, "Registry: registry_url_get('%s', %zu): allocating %zu bytes", url, urllen, sizeof(REGISTRY_URL) + urllen);
39 u = callocz(1, sizeof(REGISTRY_URL) + urllen); // no need for +1, 1 is already in REGISTRY_URL
registry/registry_url.h
+1 -1
@@ -12,7 +12,7 @@
12 // we store them here and we keep pointers elsewhere
13
14 struct registry_url {
15 - avl avl;
15 + avl_t avl;
16 uint32_t hash; // the index hash
17
18 uint32_t links; // the number of links to this URL - when none is left, we free it
spawn/spawn.c
+7 -7
@@ -62,7 +62,7 @@ uint64_t spawn_enq_cmd(char *command_to_run)
62 {
63 unsigned queue_size;
64 uint64_t serial;
65 - avl *avl_ret;
65 + avl_t *avl_ret;
66 struct spawn_cmd_info *cmdinfo;
67
68 cmdinfo = create_spawn_cmd(command_to_run);
@@ -79,8 +79,8 @@ uint64_t spawn_enq_cmd(char *command_to_run)
79 cmdinfo->serial = serial; /* No need to take the cmd mutex since it is unreachable at the moment */
80
81 /* enqueue command */
82 - avl_ret = avl_insert(&spawn_cmd_queue.cmd_tree, (avl *)cmdinfo);
83 - fatal_assert(avl_ret == (avl *)cmdinfo);
82 + avl_ret = avl_insert(&spawn_cmd_queue.cmd_tree, (avl_t *)cmdinfo);
83 + fatal_assert(avl_ret == (avl_t *)cmdinfo);
84 uv_mutex_unlock(&spawn_cmd_queue.mutex);
85
86 /* wake up event loop */
@@ -93,13 +93,13 @@ uint64_t spawn_enq_cmd(char *command_to_run)
93 */
94 void spawn_wait_cmd(uint64_t serial, int *exit_status, time_t *exec_run_timestamp)
95 {
96 - avl *avl_ret;
96 + avl_t *avl_ret;
97 struct spawn_cmd_info tmp, *cmdinfo;
98
99 tmp.serial = serial;
100
101 uv_mutex_lock(&spawn_cmd_queue.mutex);
102 - avl_ret = avl_search(&spawn_cmd_queue.cmd_tree, (avl *)&tmp);
102 + avl_ret = avl_search(&spawn_cmd_queue.cmd_tree, (avl_t *)&tmp);
103 uv_mutex_unlock(&spawn_cmd_queue.mutex);
104
105 fatal_assert(avl_ret); /* Could be NULL if more than 1 threads wait for the command */
@@ -122,13 +122,13 @@ void spawn_wait_cmd(uint64_t serial, int *exit_status, time_t *exec_run_timestam
122 void spawn_deq_cmd(struct spawn_cmd_info *cmdinfo)
123 {
124 unsigned queue_size;
125 - avl *avl_ret;
125 + avl_t *avl_ret;
126
127 uv_mutex_lock(&spawn_cmd_queue.mutex);
128 queue_size = spawn_cmd_queue.size;
129 fatal_assert(queue_size);
130 /* dequeue command */
131 - avl_ret = avl_remove(&spawn_cmd_queue.cmd_tree, (avl *)cmdinfo);
131 + avl_ret = avl_remove(&spawn_cmd_queue.cmd_tree, (avl_t *)cmdinfo);
132 fatal_assert(avl_ret);
133
134 spawn_cmd_queue.size = queue_size - 1;
spawn/spawn.h
+1 -1
@@ -42,7 +42,7 @@ struct spawn_prot_header {
42 #define SPAWN_CMD_DONE 0x00000008
43
44 struct spawn_cmd_info {
45 - avl avl;
45 + avl_t avl;
46
47 /* concurrency control per command */
48 uv_mutex_t mutex;
spawn/spawn_server.c
+6 -6
@@ -16,7 +16,7 @@ static char prot_buffer[MAX_COMMAND_LENGTH];
16 static unsigned prot_buffer_len = 0;
17
18 struct spawn_execution_info {
19 - avl avl;
19 + avl_t avl;
20
21 void *handle;
22 int exit_status;
@@ -106,7 +106,7 @@ static void wait_children(void *arg)
106 {
107 siginfo_t i;
108 struct spawn_execution_info tmp, *exec_info;
109 - avl *ret_avl;
109 + avl_t *ret_avl;
110
111 (void)arg;
112 while (!server_shutdown) {
@@ -133,7 +133,7 @@ static void wait_children(void *arg)
133 #endif
134 fatal_assert(CLD_EXITED == i.si_code);
135 tmp.pid = (pid_t)i.si_pid;
136 - while (NULL == (ret_avl = avl_remove_lock(&spawn_outstanding_exec_tree, (avl *)&tmp))) {
136 + while (NULL == (ret_avl = avl_remove_lock(&spawn_outstanding_exec_tree, (avl_t *)&tmp))) {
137 fprintf(stderr,
138 "SPAWN: race condition detected, waiting for child process %d to be indexed.\n",
139 (int)tmp.pid);
@@ -153,7 +153,7 @@ void spawn_protocol_execute_command(void *handle, char *command_to_run, uint16_t
153 {
154 uv_buf_t writebuf[2];
155 int ret;
156 - avl *avl_ret;
156 + avl_t *avl_ret;
157 struct spawn_execution_info *exec_info;
158 struct write_context *write_ctx;
159
@@ -174,8 +174,8 @@ void spawn_protocol_execute_command(void *handle, char *command_to_run, uint16_t
174 exec_info = mallocz(sizeof(*exec_info));
175 exec_info->handle = handle;
176 exec_info->pid = write_ctx->spawn_result.exec_pid;
177 - avl_ret = avl_insert_lock(&spawn_outstanding_exec_tree, (avl *)exec_info);
178 - fatal_assert(avl_ret == (avl *)exec_info);
177 + avl_ret = avl_insert_lock(&spawn_outstanding_exec_tree, (avl_t *)exec_info);
178 + fatal_assert(avl_ret == (avl_t *)exec_info);
179
180 /* wake up the thread that blocks waiting for processes to exit */
181 uv_mutex_lock(&wait_children_mutex);