diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-10-08 21:27:18 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-10-08 21:27:18 +0000 |
commit | ec6c52fd36c3c838825fb791aab4dfaf8c4c93d3 (patch) | |
tree | e643a7e56ca2e9d2cbed92c0ca6bb526b7d95b65 | |
parent | 4987cf3134f116d1881602141ccc5ee7d572b8de (diff) | |
download | gamma-ec6c52fd36c3c838825fb791aab4dfaf8c4c93d3.tar.gz gamma-ec6c52fd36c3c838825fb791aab4dfaf8c4c93d3.tar.bz2 |
(num_iface): Static
(sql_register_iface): Avoid registering the same interface twice.
-rw-r--r-- | src/gsql_conn.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gsql_conn.c b/src/gsql_conn.c index 4a48de7..3a44c18 100644 --- a/src/gsql_conn.c +++ b/src/gsql_conn.c @@ -13,25 +13,25 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <string.h> #include <guile-sql.h> #include <app.h> -int num_iface; +static int num_iface; struct sql_iface sql_iftab[MAX_IFACES]; SCM_GLOBAL_SYMBOL (gsql_error, "gsql-error"); long sql_connect_tag; /* SMOB functions: */ static SCM sql_connect_mark (SCM connect_smob) { struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob); @@ -196,24 +196,27 @@ SCM_DEFINE (sql_query, "sql-query", 2, 0, 0, SCM_ASSERT(scm_is_sql_connect(CONN), CONN, SCM_ARG1, FUNC_NAME); SCM_ASSERT(SCM_STRINGP(QUERY), QUERY, SCM_ARG2, FUNC_NAME); conn = (struct sql_connect *)SCM_CDR(CONN); query = SCM_ROCHARS(QUERY); return sql_iftab[conn->iface].query(conn, query); } #undef FUNC_NAME int sql_register_iface(struct sql_iface *ifp) { + int n = sql_find_iface(ifp->name); + if (n != -1) + return n; if (num_iface >= MAX_IFACES) scm_misc_error("sql_register_iface", "Too many ifaces registered", SCM_EOL); memcpy(&sql_iftab[num_iface], ifp, sizeof sql_iftab[0]); sql_iftab[num_iface].name = strdup(ifp->name); return num_iface++; } void gsql_conn_init() { |