aboutsummaryrefslogtreecommitdiff
path: root/src/sql.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql.c')
-rw-r--r--src/sql.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/sql.c b/src/sql.c
index 1381ff2..65cc5df 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -19,11 +19,11 @@
/* Singly-linked list of configured MySQL connections. */
struct sql_list {
- struct sql_list *next;
+ SLIST_ENTRY(sql_list) link;
struct sqlconn conn;
};
-static struct sql_list *sql_list;
+static SLIST_HEAD(,sql_list) sql_head = SLIST_HEAD_INITIALIZER(sql_head);
/* Append CONN to the end of sql_list */
void
@@ -31,8 +31,7 @@ sql_register_conn(struct sqlconn *conn)
{
struct sql_list *ent = grecs_malloc(sizeof *ent);
ent->conn = *conn;
- ent->next = sql_list;
- sql_list = ent;
+ SLIST_INSERT_HEAD(&sql_head, ent, link);
}
/* Find a configured connection that has the given IDENT */
@@ -40,9 +39,10 @@ struct sqlconn *
sql_find_connection(const char *ident)
{
struct sql_list *p;
- for (p = sql_list; p; p = p->next)
+ SLIST_FOREACH(p, &sql_head, link) {
if (strcmp(p->conn.ident, ident) == 0)
return &p->conn;
+ }
return NULL;
}

Return to:

Send suggestions and report system problems to the System administrator.