|
118 | 118 | #define ANYELEMENTOID 2283
|
119 | 119 | #define JSONBOID 3802
|
120 | 120 |
|
121 |
| -static value v_None = Val_int(0); |
122 |
| - |
123 |
| -static inline value make_some(value v) |
124 |
| -{ |
125 |
| - CAMLparam1(v); |
126 |
| - value v_res = caml_alloc_small(1, 0); |
127 |
| - Field(v_res, 0) = v; |
128 |
| - CAMLreturn(v_res); |
129 |
| -} |
130 |
| - |
131 | 121 | /* Cache for OCaml-values */
|
132 | 122 | static value v_empty_string = Val_unit;
|
133 | 123 | static const value *v_exc_Oid = NULL; /* Exception [Oid] */
|
@@ -338,13 +328,14 @@ CAMLprim value PQconndefaults_stub(value __unused v_unit)
|
338 | 328 |
|
339 | 329 | for (i = 0; i < n; i++, p++) {
|
340 | 330 | v_el = caml_alloc_small(7, 0);
|
341 |
| - for (j = 0; j < 7; j++) Field(v_el, j) = v_None; |
| 331 | + for (j = 0; j < 7; j++) Field(v_el, j) = Val_none; |
342 | 332 | Store_field(v_res, i, v_el);
|
343 | 333 | Store_field(v_el, 0, caml_copy_string(p->keyword));
|
344 |
| - if (p->envvar) Store_field(v_el, 1, make_some(caml_copy_string(p->envvar))); |
| 334 | + if (p->envvar) |
| 335 | + Store_field(v_el, 1, caml_alloc_some(caml_copy_string(p->envvar))); |
345 | 336 | if (p->compiled)
|
346 |
| - Store_field(v_el, 2, make_some(caml_copy_string(p->compiled))); |
347 |
| - if (p->val) Store_field(v_el, 3, make_some(caml_copy_string(p->val))); |
| 337 | + Store_field(v_el, 2, caml_alloc_some(caml_copy_string(p->compiled))); |
| 338 | + if (p->val) Store_field(v_el, 3, caml_alloc_some(caml_copy_string(p->val))); |
348 | 339 | Store_field(v_el, 4, caml_copy_string(p->label));
|
349 | 340 | Store_field(v_el, 5, caml_copy_string(p->dispchar));
|
350 | 341 | Store_field(v_el, 6, Val_int(p->dispsize));
|
@@ -1158,16 +1149,16 @@ CAMLprim value PQCancel_stub(value v_conn)
|
1158 | 1149 | {
|
1159 | 1150 | CAMLparam1(v_conn);
|
1160 | 1151 | PGconn *conn = get_conn(v_conn);
|
1161 |
| - if (conn == NULL) CAMLreturn(v_None); |
| 1152 | + if (conn == NULL) CAMLreturn(Val_none); |
1162 | 1153 | else {
|
1163 | 1154 | PGcancel *cancel = get_cancel_obj(v_conn);
|
1164 | 1155 | char errbuf[256];
|
1165 | 1156 | int res;
|
1166 | 1157 | caml_enter_blocking_section();
|
1167 | 1158 | res = PQcancel(cancel, errbuf, 256);
|
1168 | 1159 | caml_leave_blocking_section();
|
1169 |
| - if (res == 0) CAMLreturn(make_some(caml_copy_string(errbuf))); |
1170 |
| - else CAMLreturn(v_None); |
| 1160 | + if (res == 0) CAMLreturn(caml_alloc_some(caml_copy_string(errbuf))); |
| 1161 | + else CAMLreturn(Val_none); |
1171 | 1162 | }
|
1172 | 1163 | }
|
1173 | 1164 |
|
@@ -1259,9 +1250,9 @@ CAMLprim value PQnotifies_stub(value v_conn)
|
1259 | 1250 | Field(v_notif, 1) = Val_int(notif->be_pid);
|
1260 | 1251 | Field(v_notif, 2) = v_extra;
|
1261 | 1252 | PQfreemem(notif);
|
1262 |
| - CAMLreturn(make_some(v_notif)); |
| 1253 | + CAMLreturn(caml_alloc_some(v_notif)); |
1263 | 1254 | }
|
1264 |
| - else CAMLreturn(v_None); |
| 1255 | + else CAMLreturn(Val_none); |
1265 | 1256 | }
|
1266 | 1257 |
|
1267 | 1258 | /* Functions Associated with the COPY Command */
|
|
0 commit comments