From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA17870; Sun, 7 Jul 2002 11:19:50 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA17688 for caml-list@pauillac.inria.fr; Sun, 7 Jul 2002 11:19:49 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA09079 for ; Sat, 6 Jul 2002 22:03:35 +0200 (MET DST) Received: from tema.sit (host-81.uni.net.ua [213.169.83.81]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g66K3Uf29619 for ; Sat, 6 Jul 2002 22:03:31 +0200 (MET DST) Received: (from tema@localhost) by tema.sit (8.9.3/8.9.3) id XAA17480; Sat, 6 Jul 2002 23:02:52 +0300 X-Authentication-Warning: tema.sit: tema set sender to tema@sit.kiev.ua using -f Date: Sat, 6 Jul 2002 23:02:52 +0300 From: Artem Prisyaznuk To: shawnw@speakeasy.org Cc: caml-list@inria.fr Subject: [Caml-list] Patch to ocaml-mysql Message-ID: <20020706200251.GA17257@sit.kiev.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Operating-System: Linux tema 2.2.14-5.0 X-Uptime: 10:44pm up 2 days, 8:34, 3 users, load average: 0.08, 0.02, 0.03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello I found in Ocaml-MySql binding 0.1.1 some bugs. It broken garbage collector, because it's not correct operate with Ocaml/C interface. If during working program, GC run major cycle, program don't working properly after what. It's problem explained here: http://caml.inria.fr/archives/200002/msg00065.html I change some part of code, now it's working Ok. Diff output like this: diff -u -r ocaml-mysql-0.1.1/configure ocaml-mysql-0.1.2/configure --- ocaml-mysql-0.1.1/configure Mon Apr 22 22:38:01 2002 +++ ocaml-mysql-0.1.2/configure Tue Jul 2 15:56:46 2002 @@ -2173,6 +2173,7 @@ echo "$as_me: checking for MySQL libraries..." >&6;} dirs="/usr/local/lib/mysql /usr/local/mysql/lib + /usr/local/mysql/lib/mysql /usr/local/lib /usr/lib /usr/lib/mysql" diff -u -r ocaml-mysql-0.1.1/ocmysql.c ocaml-mysql-0.1.2/ocmysql.c --- ocaml-mysql-0.1.1/ocmysql.c Mon May 6 02:15:39 2002 +++ ocaml-mysql-0.1.2/ocmysql.c Fri Jul 5 10:42:17 2002 @@ -99,8 +99,8 @@ v = alloc_string(length); memcpy(String_val(v), s, length); - res = alloc_small(1,SOME); - Field(res,0) = v; + res = alloc(1,SOME); + Store_field(res,0,v); } CAMLreturn(res); } @@ -116,8 +116,8 @@ CAMLlocal2(res, v); v = some; - res = alloc_small(1,SOME); - Field(res,0) = v; + res = alloc(1,SOME); + Store_field(res,0,v); CAMLreturn(res); } @@ -175,8 +175,8 @@ mysqlfailwith(mysql_error(init)); } else { res = alloc_final(3, conn_finalize, 100,1000); - Store_field(res, 1, (value)mysql); - Store_field(res, 2, Val_true); + Field(res, 1) = (value)mysql; + Field(res, 2) = Val_true; } } CAMLreturn(res); @@ -224,15 +224,13 @@ dbs = alloc_tuple(n); /* Array */ i = 0; while ((row = mysql_fetch_row(res)) != NULL) { - CAMLlocal1(s); - s = copy_string(row[0]); - Store_field(dbs, i, s); + Store_field(dbs, i, copy_string(row[0])); i++; } mysql_free_result(res); - out = alloc_small(1, SOME); - Field(out, 0) = dbs; + out = alloc(1, SOME); + Store_field(out, 0, dbs); CAMLreturn(out); } @@ -259,8 +257,8 @@ CAMLparam1(dbd); check_dbd(dbd,"disconnect"); mysql_close(DBDmysql(dbd)); - Store_field(dbd, 1, Val_false); - Store_field(dbd, 2, Val_false); /* Mark closed */ + Field(dbd, 1) = Val_false; + Field(dbd, 2) = Val_false; /* Mark closed */ CAMLreturn0; } @@ -313,7 +311,7 @@ } else { res = alloc_final(2, res_finalize, 1, 20); - Store_field(res, 1, (value) mysql_store_result(DBDmysql(dbd))); + Field(res, 1) = ((value) mysql_store_result(DBDmysql(dbd))); } CAMLreturn(res); @@ -354,9 +352,7 @@ length = mysql_fetch_lengths(res); /* length[] */ fields = alloc_tuple(n); /* array */ for (i=0;i