diff options
Diffstat (limited to 'src/sql.c')
-rw-r--r-- | src/sql.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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; } |