28
28
#include <stdio.h>
29
29
#include <string.h>
30
30
31
+ #include <caml/version.h>
31
32
#include <caml/mlvalues.h>
32
33
#include <caml/memory.h>
33
34
#include <caml/fail.h>
@@ -420,7 +421,9 @@ static struct custom_operations db_wrap_ops = {
420
421
custom_serialize_default ,
421
422
custom_deserialize_default ,
422
423
custom_compare_ext_default ,
423
- custom_fixed_length_default
424
+ #if (OCAML_VERSION_MAJOR >= 4 && OCAML_VERSION_MINOR >= 8 )
425
+ custom_fixed_length_default ,
426
+ #endif
424
427
};
425
428
426
429
#ifdef SQLITE_HAS_OPEN_V2
@@ -540,7 +543,11 @@ CAMLprim value caml_sqlite3_open(
540
543
int mem , hiwtr ;
541
544
int rc = sqlite3_db_status (db , SQLITE_DBSTATUS_CACHE_USED , & mem , & hiwtr , 0 );
542
545
mem = db_wrap_size + (rc ? 8192 : mem );
546
+ #if (OCAML_VERSION_MAJOR >= 4 && OCAML_VERSION_MINOR >= 8 )
543
547
v_res = caml_alloc_custom_mem (& db_wrap_ops , sizeof (db_wrap * ), mem );
548
+ #else
549
+ v_res = caml_alloc_custom (& db_wrap_ops , sizeof (db_wrap * ), 1 , 1000 );
550
+ #endif
544
551
dbw -> db = db ;
545
552
dbw -> rc = SQLITE_OK ;
546
553
dbw -> ref_count = 1 ;
@@ -875,7 +882,9 @@ static struct custom_operations stmt_wrap_ops = {
875
882
custom_serialize_default ,
876
883
custom_deserialize_default ,
877
884
custom_compare_ext_default ,
885
+ #if (OCAML_VERSION_MAJOR >= 4 && OCAML_VERSION_MINOR >= 8 )
878
886
custom_fixed_length_default
887
+ #endif
879
888
};
880
889
881
890
static inline value prepare_it (
@@ -897,11 +906,16 @@ static inline value prepare_it(
897
906
if (rc != SQLITE_OK ) raise_sqlite3_current (dbw -> db , loc );
898
907
raise_sqlite3_Error ("No code compiled from %s" , sql );
899
908
} else {
909
+ #if (OCAML_VERSION_MAJOR >= 4 && OCAML_VERSION_MINOR >= 8 )
900
910
size_t mem =
901
911
sizeof (stmt_wrap ) + sql_len + 1 +
902
912
sqlite3_stmt_status (stmtw -> stmt , SQLITE_STMTSTATUS_MEMUSED , 0 );
903
913
value v_stmt =
904
914
caml_alloc_custom_mem (& stmt_wrap_ops , sizeof (stmt_wrap * ), mem );
915
+ #else
916
+ value v_stmt =
917
+ caml_alloc_custom (& stmt_wrap_ops , sizeof (stmt_wrap * ), 1 , 1000 );
918
+ #endif
905
919
Sqlite3_stmtw_val (v_stmt ) = stmtw ;
906
920
return v_stmt ;
907
921
}
0 commit comments