@@ -265,7 +265,7 @@ CAMLprim value PQconnectdb_stub(value v_conn_info, value v_startonly)
265
265
caml_enter_blocking_section ();
266
266
conn = PQconnectdb (conn_info );
267
267
cancel = PQgetCancel (conn );
268
- free (conn_info );
268
+ caml_stat_free (conn_info );
269
269
caml_leave_blocking_section ();
270
270
}
271
271
@@ -466,8 +466,8 @@ static inline void copy_binary_params(
466
466
467
467
static inline void free_binary_params (int * formats , int * lengths )
468
468
{
469
- if (formats != NULL ) free (formats );
470
- if (lengths != NULL ) free (lengths );
469
+ if (formats != NULL ) caml_stat_free (formats );
470
+ if (lengths != NULL ) caml_stat_free (lengths );
471
471
}
472
472
473
473
static inline const char * const * copy_params (value v_params , size_t nparams )
@@ -493,7 +493,7 @@ static inline void free_params(const char * const *params, size_t nparams)
493
493
size_t i ;
494
494
if (nparams == 0 ) return ;
495
495
for (i = 0 ; i < nparams ; i ++ ) caml_stat_free ((char * ) params [i ]);
496
- free ((char * * ) params );
496
+ caml_stat_free ((char * * ) params );
497
497
}
498
498
499
499
static inline const char * const * copy_params_shallow (
@@ -514,7 +514,7 @@ static inline void free_params_shallow(
514
514
const char * const * params , size_t nparams )
515
515
{
516
516
if (nparams == 0 ) return ;
517
- free ((char * * ) params );
517
+ caml_stat_free ((char * * ) params );
518
518
}
519
519
520
520
CAMLprim value PQexecParams_stub (
@@ -538,7 +538,7 @@ CAMLprim value PQexecParams_stub(
538
538
: PQexecParams (conn , query , nparams , NULL , params , lengths , formats , 0 );
539
539
free_binary_params (formats , lengths );
540
540
free_params (params , nparams );
541
- free (query );
541
+ caml_stat_free (query );
542
542
caml_leave_blocking_section ();
543
543
CAMLreturn (alloc_result (res , np_cb ));
544
544
}
@@ -558,8 +558,8 @@ CAMLprim value PQprepare_stub(value v_conn, value v_stm_name, value v_query)
558
558
memcpy (query , String_val (v_query ), query_len );
559
559
caml_enter_blocking_section ();
560
560
res = PQprepare (conn , stm_name , query , 0 , NULL );
561
- free (stm_name );
562
- free (query );
561
+ caml_stat_free (stm_name );
562
+ caml_stat_free (query );
563
563
caml_leave_blocking_section ();
564
564
CAMLreturn (alloc_result (res , np_cb ));
565
565
#else
@@ -588,7 +588,7 @@ CAMLprim value PQexecPrepared_stub(
588
588
memcpy (stm_name , String_val (v_stm_name ), len );
589
589
caml_enter_blocking_section ();
590
590
res = PQexecPrepared (conn , stm_name , nparams , params , lengths , formats , 0 );
591
- free (stm_name );
591
+ caml_stat_free (stm_name );
592
592
free_binary_params (formats , lengths );
593
593
free_params (params , nparams );
594
594
caml_leave_blocking_section ();
@@ -615,7 +615,7 @@ CAMLprim value PQdescribePrepared_stub(value v_conn, value v_query)
615
615
memcpy (query , String_val (v_query ), len );
616
616
caml_enter_blocking_section ();
617
617
res = PQdescribePrepared (conn , query );
618
- free (query );
618
+ caml_stat_free (query );
619
619
caml_leave_blocking_section ();
620
620
CAMLreturn (alloc_result (res , np_cb ));
621
621
#else
@@ -867,21 +867,21 @@ CAMLprim value PQescapeStringConn_stub(
867
867
{
868
868
size_t len = Long_val (v_len );
869
869
size_t to_len = len + len + 1 ;
870
- char * buf = malloc (to_len );
870
+ char * buf = caml_stat_alloc (to_len );
871
871
int error ;
872
872
size_t n_written =
873
873
PQescapeStringConn (
874
874
get_conn (v_conn ),
875
875
buf , String_val (v_from ) + Long_val (v_pos_from ),
876
876
len , & error );
877
877
if (error ) {
878
- free (buf );
878
+ caml_stat_free (buf );
879
879
caml_failwith ("Postgresql.escape_string_conn: failed to escape string" );
880
880
return Val_unit ;
881
881
} else {
882
882
value v_res = caml_alloc_string (n_written );
883
883
memcpy (String_val (v_res ), buf , n_written );
884
- free (buf );
884
+ caml_stat_free (buf );
885
885
return v_res ;
886
886
}
887
887
}
@@ -1017,7 +1017,7 @@ CAMLprim value PQgetline_stub(
1017
1017
v_res = Val_int (PQgetline (conn , buf , len ));
1018
1018
caml_leave_blocking_section ();
1019
1019
memcpy (String_val (v_buf ) + Long_val (v_pos ), buf , len );
1020
- free (buf );
1020
+ caml_stat_free (buf );
1021
1021
CAMLreturn (v_res );
1022
1022
}
1023
1023
@@ -1039,7 +1039,7 @@ CAMLprim value PQputline_stub(value v_conn, value v_buf)
1039
1039
memcpy (buf , String_val (v_buf ), len );
1040
1040
caml_enter_blocking_section ();
1041
1041
v_res = Val_int (PQputline (conn , buf ));
1042
- free (buf );
1042
+ caml_stat_free (buf );
1043
1043
caml_leave_blocking_section ();
1044
1044
CAMLreturn (v_res );
1045
1045
}
@@ -1055,7 +1055,7 @@ CAMLprim value PQputnbytes_stub(
1055
1055
memcpy (buf , String_val (v_buf ) + Long_val (v_pos ), len );
1056
1056
caml_enter_blocking_section ();
1057
1057
v_res = Val_int (PQputnbytes (conn , buf , len ));
1058
- free (buf );
1058
+ caml_stat_free (buf );
1059
1059
caml_leave_blocking_section ();
1060
1060
CAMLreturn (v_res );
1061
1061
}
@@ -1131,7 +1131,7 @@ CAMLprim value lo_read_stub(value v_conn, value v_fd,
1131
1131
v_res = Val_long (lo_read (conn , Int_val (v_fd ), buf , len ));
1132
1132
caml_leave_blocking_section ();
1133
1133
memcpy (String_val (v_buf ) + Long_val (v_pos ), buf , len );
1134
- free (buf );
1134
+ caml_stat_free (buf );
1135
1135
CAMLreturn (v_res );
1136
1136
}
1137
1137
@@ -1160,7 +1160,7 @@ CAMLprim value lo_write_stub(value v_conn, value v_fd,
1160
1160
memcpy (buf , String_val (v_buf ) + Long_val (v_pos ), len );
1161
1161
caml_enter_blocking_section ();
1162
1162
v_res = Val_long (lo_write (conn , Int_val (v_fd ), buf , len ));
1163
- free (buf );
1163
+ caml_stat_free (buf );
1164
1164
caml_leave_blocking_section ();
1165
1165
CAMLreturn (v_res );
1166
1166
}
@@ -1241,7 +1241,7 @@ CAMLprim value lo_import_stub(value v_conn, value v_fname)
1241
1241
memcpy (fname , String_val (v_fname ), len );
1242
1242
caml_enter_blocking_section ();
1243
1243
v_res = Val_int (lo_import (conn , fname ));
1244
- free (fname );
1244
+ caml_stat_free (fname );
1245
1245
caml_leave_blocking_section ();
1246
1246
CAMLreturn (v_res );
1247
1247
}
@@ -1256,7 +1256,7 @@ CAMLprim value lo_export_stub(value v_conn, value v_oid, value v_fname)
1256
1256
memcpy (fname , String_val (v_fname ), len );
1257
1257
caml_enter_blocking_section ();
1258
1258
v_res = Val_int (lo_export (conn , Int_val (v_oid ), fname ));
1259
- free (fname );
1259
+ caml_stat_free (fname );
1260
1260
caml_leave_blocking_section ();
1261
1261
CAMLreturn (v_res );
1262
1262
}
0 commit comments