Skip to content

Commit f83b965

Browse files
committed
Added support for const char strings in stubs
1 parent 347052b commit f83b965

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/postgresql_stubs.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ static inline void free_params(const char * const *params, size_t nparams)
614614
static inline const char * const * copy_params_shallow(
615615
value v_params, size_t nparams)
616616
{
617-
char **params;
617+
const char **params;
618618
size_t i;
619619
if (nparams == 0) return NULL;
620620
params = caml_stat_alloc(nparams * sizeof(char *));
@@ -917,7 +917,7 @@ CAMLprim value PQgetescval_stub(value v_res, intnat tup_num, intnat field_num)
917917
str += 2;
918918
n_hex_pairs = bytea_hex_pairs(str);
919919
v_str = caml_alloc_string(n_hex_pairs);
920-
decode_bytea_hex(str, String_val(v_str), n_hex_pairs);
920+
decode_bytea_hex(str, (char *) String_val(v_str), n_hex_pairs);
921921
}
922922
} else {
923923
/* Assume binary format! */
@@ -1193,7 +1193,8 @@ CAMLprim value PQunescapeBytea_stub(value v_from)
11931193
CAMLparam1(v_from);
11941194
value v_res = caml_alloc_string(res_len);
11951195
/* GC may have happened, have to use String_val on v_from again */
1196-
decode_bytea_hex(String_val(v_from) + 2, String_val(v_res), res_len);
1196+
decode_bytea_hex(
1197+
String_val(v_from) + 2, (char *) String_val(v_res), res_len);
11971198
CAMLreturn(v_res);
11981199
}
11991200
}
@@ -1316,7 +1317,7 @@ CAMLprim intnat PQgetline_stub(
13161317
caml_enter_blocking_section();
13171318
res = PQgetline(conn, buf, len);
13181319
caml_leave_blocking_section();
1319-
memcpy(String_val(v_buf) + pos, buf, len);
1320+
memcpy(Bytes_val(v_buf) + pos, buf, len);
13201321
caml_stat_free(buf);
13211322
CAMLreturn(res);
13221323
}
@@ -1330,7 +1331,8 @@ CAMLprim value PQgetline_stub_bc(
13301331
CAMLprim intnat PQgetlineAsync_stub(
13311332
value v_conn, value v_buf, intnat pos, intnat len)
13321333
{
1333-
return PQgetlineAsync(get_conn(v_conn), String_val(v_buf) + pos, len);
1334+
return PQgetlineAsync(
1335+
get_conn(v_conn), (char *) String_val(v_buf) + pos, len);
13341336
}
13351337

13361338
CAMLprim value PQgetlineAsync_stub_bc(
@@ -1578,7 +1580,7 @@ CAMLprim intnat lo_read_stub(
15781580
caml_enter_blocking_section();
15791581
res = lo_read(conn, fd, buf, len);
15801582
caml_leave_blocking_section();
1581-
memcpy(String_val(v_buf) + pos, buf, len);
1583+
memcpy(Bytes_val(v_buf) + pos, buf, len);
15821584
caml_stat_free(buf);
15831585
CAMLreturn(res);
15841586
}

0 commit comments

Comments
 (0)