@@ -1217,8 +1217,7 @@ CAMLprim value caml_sqlite3_column_blob(value v_stmt, intnat pos)
12171217 sqlite3_stmt * stmt = safe_get_stmtw ("column_blob" , v_stmt )-> stmt ;
12181218 range_check (pos , sqlite3_column_count (stmt ));
12191219 len = sqlite3_column_bytes (stmt , pos );
1220- v_str = caml_alloc_string (len );
1221- memcpy (String_val (v_str ), sqlite3_column_blob (stmt , pos ), len );
1220+ v_str = caml_alloc_initialized_string (len , sqlite3_column_blob (stmt , pos ));
12221221 CAMLreturn (v_str );
12231222}
12241223
@@ -1279,8 +1278,8 @@ CAMLprim value caml_sqlite3_column_text(value v_stmt, intnat pos)
12791278 sqlite3_stmt * stmt = safe_get_stmtw ("column_text" , v_stmt )-> stmt ;
12801279 range_check (pos , sqlite3_column_count (stmt ));
12811280 len = sqlite3_column_bytes (stmt , pos );
1282- v_str = caml_alloc_string ( len );
1283- memcpy ( String_val ( v_str ), sqlite3_column_text (stmt , pos ), len );
1281+ v_str =
1282+ caml_alloc_initialized_string ( len , ( char * ) sqlite3_column_text (stmt , pos ));
12841283 CAMLreturn (v_str );
12851284}
12861285
@@ -1312,15 +1311,16 @@ CAMLprim value caml_sqlite3_column(value v_stmt, intnat pos)
13121311 break ;
13131312 case SQLITE3_TEXT :
13141313 len = sqlite3_column_bytes (stmt , pos );
1315- v_tmp = caml_alloc_string (len );
1316- memcpy (String_val (v_tmp ), (char * ) sqlite3_column_text (stmt , pos ), len );
1314+ v_tmp =
1315+ caml_alloc_initialized_string (
1316+ len , (char * ) sqlite3_column_text (stmt , pos ));
13171317 v_res = caml_alloc_small (1 , 2 );
13181318 Field (v_res , 0 ) = v_tmp ;
13191319 break ;
13201320 case SQLITE_BLOB :
13211321 len = sqlite3_column_bytes (stmt , pos );
1322- v_tmp = caml_alloc_string ( len );
1323- memcpy ( String_val ( v_tmp ), ( char * ) sqlite3_column_blob (stmt , pos ), len );
1322+ v_tmp =
1323+ caml_alloc_initialized_string ( len , sqlite3_column_blob (stmt , pos ));
13241324 v_res = caml_alloc_small (1 , 3 );
13251325 Field (v_res , 0 ) = v_tmp ;
13261326 break ;
@@ -1380,15 +1380,15 @@ static inline value caml_sqlite3_wrap_values(int argc, sqlite3_value **args)
13801380 break ;
13811381 case SQLITE3_TEXT :
13821382 len = sqlite3_value_bytes (arg );
1383- v_tmp = caml_alloc_string (len );
1384- memcpy (String_val (v_tmp ), (char * ) sqlite3_value_text (arg ), len );
1383+ v_tmp =
1384+ caml_alloc_initialized_string (
1385+ len , (char * ) sqlite3_value_text (arg ));
13851386 v_res = caml_alloc_small (1 , 2 );
13861387 Field (v_res , 0 ) = v_tmp ;
13871388 break ;
13881389 case SQLITE_BLOB :
13891390 len = sqlite3_value_bytes (arg );
1390- v_tmp = caml_alloc_string (len );
1391- memcpy (String_val (v_tmp ), (char * ) sqlite3_value_blob (arg ), len );
1391+ v_tmp = caml_alloc_initialized_string (len , sqlite3_value_blob (arg ));
13921392 v_res = caml_alloc_small (1 , 3 );
13931393 Field (v_res , 0 ) = v_tmp ;
13941394 break ;
0 commit comments