summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2013-04-14 09:07:57 +0200
committerYorhel <git@yorhel.nl>2013-04-14 09:07:57 +0200
commitb6ad61b41abcdffb2123ca275475a5f2aa81bf24 (patch)
tree9a4e94e8a2296639bc12f04ad7d072edd8ead8a4
parentd55f73562739b2a0b0bb79d939a82a826bbe1dfc (diff)
hub: Get rid of pointer indirection for hub_adc and hub_nmdc structs
The indirection is neither more clear/simple nor any more efficient.
-rw-r--r--src/hub/adc.c4
-rw-r--r--src/hub/adc.h2
-rw-r--r--src/hub/connection.c4
-rw-r--r--src/hub/hub.c2
-rw-r--r--src/hub/manager.c2
-rw-r--r--src/hub/nmdc.c4
-rw-r--r--src/hub/nmdc.h2
-rw-r--r--src/hub/users.c4
8 files changed, 10 insertions, 14 deletions
diff --git a/src/hub/adc.c b/src/hub/adc.c
index 21e7dcf..aa7d2d6 100644
--- a/src/hub/adc.c
+++ b/src/hub/adc.c
@@ -644,7 +644,7 @@ static void hub_adc_disconnected(hub_t *h) {
}
-static const hub_proto_t hub__adc = {
+const hub_proto_t hub_adc = {
hub_adc_connected,
hub_adc_disconnected,
hub_adc_sendinf,
@@ -653,6 +653,4 @@ static const hub_proto_t hub__adc = {
hub_adc_read
};
-const hub_proto_t *hub_adc = &hub__adc;
-
/* vim: set noet sw=4 ts=4: */
diff --git a/src/hub/adc.h b/src/hub/adc.h
index 1c26c1c..8241eb7 100644
--- a/src/hub/adc.h
+++ b/src/hub/adc.h
@@ -42,7 +42,7 @@ typedef struct {
bool zlibenable : 1;
} hub_adc_t;
-extern const hub_proto_t *hub_adc;
+extern const hub_proto_t hub_adc;
#endif
/* vim: set noet sw=4 ts=4: */
diff --git a/src/hub/connection.c b/src/hub/connection.c
index 7e57fbd..59905cb 100644
--- a/src/hub/connection.c
+++ b/src/hub/connection.c
@@ -213,8 +213,8 @@ static void hub_conn_connect(hub_t *h, const char *addr, DBusMessage *msg) {
return;
}
- h->proto = strcmp(uri.scheme, "adc") == 0 || strcmp(uri.scheme, "adcs") == 0 ? hub_adc : hub_nmdc;
- if(!uri.port && h->proto == hub_adc) {
+ h->proto = strcmp(uri.scheme, "adc") == 0 || strcmp(uri.scheme, "adcs") == 0 ? &hub_adc : &hub_nmdc;
+ if(!uri.port && h->proto == &hub_adc) {
yinfo("%d: Address '%s' is missing a port", h->id, addr);
if(msg)
dbo_sendfree(dbus_message_new_error_printf(msg, DBUS_ERROR_INVALID_ARGS, "Missing port"));
diff --git a/src/hub/hub.c b/src/hub/hub.c
index 4e6fc6a..c976ebd 100644
--- a/src/hub/hub.c
+++ b/src/hub/hub.c
@@ -135,7 +135,7 @@ void hub_hub_infchange(hub_t *h, bool important) {
/* NMDC hubs tend to be more picky about $MyINFO throttling, so the timeout
* is a bit higher for those. ADC also benefits a lot from incremental
* updates. */
- double timeout = important ? 1.0 : h->proto == hub_adc ? 60.0 : 120.0;
+ double timeout = important ? 1.0 : h->proto == &hub_adc ? 60.0 : 120.0;
if(!ev_is_active(&h->h.infdelay)) {
ev_timer_init(&h->h.infdelay, hub_hub_nfo_timeout, timeout, 0.0);
ev_timer_start(EV_DEFAULT_UC_ &h->h.infdelay);
diff --git a/src/hub/manager.c b/src/hub/manager.c
index 687b144..3eb96c1 100644
--- a/src/hub/manager.c
+++ b/src/hub/manager.c
@@ -111,7 +111,7 @@ static void hub_create(int id, sqlasync_result_t *r) {
hub_t *h = calloc(1, sizeof(hub_t));
h->id = id;
h->type = HUBM_HNONE;
- h->proto = hub_adc;
+ h->proto = &hub_adc;
dbo_register(&h->dbo, path, regs, sizeof(regs)/sizeof(*regs));
#define INTVAL(v, min, max, def) (v.type == SQLITE_INTEGER && v.val.i64 >= min && v.val.i64 <= max ? v.val.i64 : def)
diff --git a/src/hub/nmdc.c b/src/hub/nmdc.c
index 73fa3f9..61abf1d 100644
--- a/src/hub/nmdc.c
+++ b/src/hub/nmdc.c
@@ -655,7 +655,7 @@ static void hub_nmdc_disconnected(hub_t *h) {
}
-static const hub_proto_t hub__nmdc = {
+const hub_proto_t hub_nmdc = {
hub_nmdc_connected,
hub_nmdc_disconnected,
hub_nmdc_sendinf,
@@ -664,6 +664,4 @@ static const hub_proto_t hub__nmdc = {
hub_nmdc_read
};
-const hub_proto_t *hub_nmdc = &hub__nmdc;
-
/* vim: set noet sw=4 ts=4: */
diff --git a/src/hub/nmdc.h b/src/hub/nmdc.h
index bc437de..ca0b8ff 100644
--- a/src/hub/nmdc.h
+++ b/src/hub/nmdc.h
@@ -43,7 +43,7 @@ typedef struct {
} hub_nmdc_t;
-extern const hub_proto_t *hub_nmdc;
+extern const hub_proto_t hub_nmdc;
#endif
/* vim: set noet sw=4 ts=4: */
diff --git a/src/hub/users.c b/src/hub/users.c
index 056d753..873f233 100644
--- a/src/hub/users.c
+++ b/src/hub/users.c
@@ -67,8 +67,8 @@ __KHASH_IMPL(ulistsid, static kh_inline, hub_user_t *, char, 0, hub_user_sid_has
static hub_user_t *hub_user_new(hub_t *h) {
hub_user_t *u;
- u = calloc(1, h->proto == hub_adc ? offsetof(hub_user_t, a) + sizeof((*u).a) : offsetof(hub_user_t, n) + sizeof((*u).n));
- u->adc = h->proto == hub_adc;
+ u = calloc(1, h->proto == &hub_adc ? offsetof(hub_user_t, a) + sizeof((*u).a) : offsetof(hub_user_t, n) + sizeof((*u).n));
+ u->adc = h->proto == &hub_adc;
u->delmark = !h->u.delmark;
u->id = -1;
u->ip4.s_addr = INADDR_ANY;