1. Jean-Charles Campagne
  2. postgresql-ocaml

Commits

Markus Mottl  committed cbb5c3f

Fixed GC bug in conndefaults function

  • Participants
  • Parent commits ec5b1ec
  • Branches default
  • Tags release-1.15.0

Comments (0)

Files changed (3)

File Changelog

View file
+2011-05-21:  Fixed GC bug in conndefaults function.
+
+             Thanks to Vijai Lulla <vijaylulla@gmail.com> for the bug report!
+
 2010-12-25:  Added support for the new bytea hex format in PostgreSQL 9.0.
 
              Thanks to Alain Frisch <alain@frisch.fr> for the initial patch!

File lib/META

View file
 name="postgresql"
-version="1.14.0"
+version="1.15.0"
 description="PostgreSQL bindings for OCaml"
 requires="unix, bigarray"
 archive(byte)="postgresql.cma"

File lib/postgresql_stubs.c

View file
 CAMLprim value PQconndefaults_stub(value __unused v_unit)
 {
   CAMLparam0();
-  CAMLlocal1(v_res);
+  CAMLlocal2(v_res, v_el);
   PQconninfoOption *cios = PQconndefaults(), *p = cios;
   int i, j, n;
 
   v_res = caml_alloc_tuple(n);
 
   for (i = 0; i < n; i++, cios++) {
-    value v_el = caml_alloc_small(7, 0);
-    for (j = 0; j < 7; j++) { Field(v_el, j) = v_None; };
+    value v_field;
+    v_el = caml_alloc_small(7, 0);
+    for (j = 0; j < 7; j++) Field(v_el, j) = v_None;
     Store_field(v_res, i, v_el);
-    Field(v_el, 0) = caml_copy_string(cios->keyword);
-    caml_modify(&Field(v_el, 1), caml_copy_string(cios->envvar));
+    v_field = caml_copy_string(cios->keyword);
+    Field(v_el, 0) = v_field;
+    v_field = caml_copy_string(cios->envvar);
+    caml_modify(&Field(v_el, 1), v_field);
     if (cios->compiled) {
-      value v_Some = make_some(caml_copy_string(cios->compiled));
-      caml_modify(&Field(v_el, 2), v_Some);
+      v_field = make_some(caml_copy_string(cios->compiled));
+      caml_modify(&Field(v_el, 2), v_field);
     };
     if (cios->val) {
-      value v_Some = make_some(caml_copy_string(cios->val));
-      caml_modify(&Field(v_el, 3), v_Some);
+      v_field = make_some(caml_copy_string(cios->val));
+      caml_modify(&Field(v_el, 3), v_field);
     };
-    caml_modify(&Field(v_el, 4), caml_copy_string(cios->label));
-    caml_modify(&Field(v_el, 5), caml_copy_string(cios->dispchar));
+    v_field = caml_copy_string(cios->label);
+    caml_modify(&Field(v_el, 4), v_field);
+    v_field = caml_copy_string(cios->dispchar);
+    caml_modify(&Field(v_el, 5), v_field);
     caml_modify(&Field(v_el, 6), Val_int(cios->dispsize));
   };
 
 CAMLprim value PQnotifies_stub(value v_conn)
 {
   CAMLparam1(v_conn);
+  CAMLlocal1(v_str);
   PGnotify *noti = PQnotifies(get_conn(v_conn));
 
   if (noti) {
-    CAMLlocal1(v_str);
     value v_pair;
     v_str = make_string(noti->relname);
     v_pair = caml_alloc_small(2, 0);