@@ -109,18 +109,8 @@ static int pthread_setspecific(pthread_key_t key, void *value)
109
109
110
110
/* Utility definitions */
111
111
112
- static const value Val_None = Val_int (0 );
113
-
114
- static inline value Val_Some (value v_arg )
115
- {
116
- CAMLparam1 (v_arg );
117
- value v_res = caml_alloc_small (1 , 0 );
118
- Field (v_res , 0 ) = v_arg ;
119
- CAMLreturn (v_res );
120
- }
121
-
122
112
static inline value Val_string_option (const char * str )
123
- { return (str == NULL ) ? Val_None : Val_Some (caml_copy_string (str )); }
113
+ { return (str == NULL ) ? Val_none : caml_alloc_some (caml_copy_string (str )); }
124
114
125
115
126
116
/* Type definitions */
@@ -340,14 +330,8 @@ static inline value copy_string_option_array(const char** strs, int len)
340
330
341
331
for (i = 0 ; i < len ; ++ i ) {
342
332
const char * str = strs [i ];
343
- if (str == NULL ) Field (v_res , i ) = Val_None ;
344
- else {
345
- value v_opt ;
346
- v_str = caml_copy_string (str );
347
- v_opt = caml_alloc_small (1 , 0 );
348
- Field (v_opt , 0 ) = v_str ;
349
- Store_field (v_res , i , v_opt );
350
- }
333
+ if (str == NULL ) Field (v_res , i ) = Val_none ;
334
+ else Store_field (v_res , i , caml_alloc_some (caml_copy_string (str )));
351
335
}
352
336
353
337
CAMLreturn (v_res );
@@ -483,7 +467,7 @@ CAMLprim value caml_sqlite3_open(
483
467
char * file ;
484
468
485
469
#ifdef SQLITE_HAS_OPEN_V2
486
- if (v_vfs_opt == Val_None ) vfs = NULL ;
470
+ if (Is_none ( v_vfs_opt ) ) vfs = NULL ;
487
471
else {
488
472
value v_vfs = Field (v_vfs_opt , 0 );
489
473
int vfs_len = caml_string_length (v_vfs ) + 1 ;
@@ -499,7 +483,7 @@ CAMLprim value caml_sqlite3_open(
499
483
Int_val (v_cache )
500
484
)
501
485
caml_failwith ("SQLite3 version < 3.5 does not support open flags" );
502
- if (v_vfs_opt != Val_None )
486
+ if (Is_some ( v_vfs_opt ) )
503
487
caml_failwith ("SQLite3 version < 3.5 does not support VFS modules" );
504
488
#endif
505
489
@@ -665,7 +649,7 @@ CAMLprim value caml_sqlite3_exec(value v_db, value v_maybe_cb, value v_sql)
665
649
cbx .cbp = & v_cb ;
666
650
cbx .exn = & v_exn ;
667
651
668
- if (v_maybe_cb != Val_None ) {
652
+ if (Is_some ( v_maybe_cb ) ) {
669
653
v_cb = Field (v_maybe_cb , 0 );
670
654
cb = exec_callback ;
671
655
}
@@ -947,9 +931,9 @@ CAMLprim value caml_sqlite3_prepare_tail(value v_stmt)
947
931
if (stmtw -> sql && stmtw -> tail && * (stmtw -> tail )) {
948
932
db_wrap * dbw = stmtw -> db_wrap ;
949
933
int tail_len = stmtw -> sql_len - (stmtw -> tail - stmtw -> sql );
950
- CAMLreturn (Val_Some (prepare_it (dbw , stmtw -> tail , tail_len , loc )));
934
+ CAMLreturn (caml_alloc_some (prepare_it (dbw , stmtw -> tail , tail_len , loc )));
951
935
}
952
- else CAMLreturn (Val_None );
936
+ else CAMLreturn (Val_none );
953
937
}
954
938
955
939
CAMLprim value caml_sqlite3_recompile (value v_stmt )
@@ -1391,7 +1375,7 @@ static inline value caml_sqlite3_wrap_values(int argc, sqlite3_value **args)
1391
1375
v_res = Val_int (1 );
1392
1376
break ;
1393
1377
default :
1394
- v_res = Val_None ;
1378
+ v_res = Val_none ;
1395
1379
}
1396
1380
Store_field (v_arr , i , v_res );
1397
1381
}
@@ -1588,8 +1572,8 @@ CAMLprim value caml_sqlite3_create_aggregate_function(
1588
1572
sqlite3_create_window_function (
1589
1573
dbw -> db , String_val (v_name ), n_args , SQLITE_UTF8 , param ,
1590
1574
caml_sqlite3_user_function_step , caml_sqlite3_user_function_final ,
1591
- v_valuefn == Val_None ? NULL : caml_sqlite3_user_function_value ,
1592
- v_inversefn == Val_None ? NULL : caml_sqlite3_user_function_inverse ,
1575
+ Is_none ( v_valuefn ) ? NULL : caml_sqlite3_user_function_value ,
1576
+ Is_none ( v_inversefn ) ? NULL : caml_sqlite3_user_function_inverse ,
1593
1577
NULL );
1594
1578
#else
1595
1579
rc = sqlite3_create_function (dbw -> db , String_val (v_name ),
0 commit comments