Skip to content

Commit cb0deed

Browse files
committed
Small allocation improvement
1 parent c0598bf commit cb0deed

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/postgresql_stubs.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,8 @@ CAMLprim value PQputCopyEnd_bc(value v_conn, value v_msg)
12611261
CAMLprim value PQgetCopyData_stub(value v_conn, intnat async)
12621262
{
12631263
CAMLparam1(v_conn);
1264-
CAMLlocal2(v_buf, v_result);
1264+
CAMLlocal1(v_buf);
1265+
value v_res;
12651266
PGconn *conn = get_conn(v_conn);
12661267
char *buf;
12671268
intnat res;
@@ -1279,9 +1280,9 @@ CAMLprim value PQgetCopyData_stub(value v_conn, intnat async)
12791280
v_buf = caml_alloc_string(res);
12801281
memcpy(String_val(v_buf), buf, res);
12811282
PQfreemem(buf);
1282-
v_result = caml_alloc(1, 0); /* Get_copy_data */
1283-
Store_field(v_result, 0, v_buf);
1284-
CAMLreturn(v_result);
1283+
v_res = caml_alloc_small(1, 0); /* Get_copy_data */
1284+
Field(v_res, 0) = v_buf;
1285+
CAMLreturn(v_res);
12851286
}
12861287
}
12871288

0 commit comments

Comments
 (0)