1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-12-22 12:23:56 +01:00

Added size_max for set determinant.

This commit is contained in:
v1j4y 2022-10-09 00:03:45 +02:00
parent 0035feb989
commit 86a92f2494

View File

@ -331,8 +331,8 @@ int64_t* qmckl_get_determinant_mo_index_beta (const qmckl_context context) {
qmckl_exit_code qmckl_set_determinant_type (const qmckl_context context, const char t);
qmckl_exit_code qmckl_set_determinant_det_num_alpha (const qmckl_context context, const int64_t det_num_alpha);
qmckl_exit_code qmckl_set_determinant_det_num_beta (const qmckl_context context, const int64_t det_num_beta);
qmckl_exit_code qmckl_set_determinant_mo_index_alpha (const qmckl_context context, const int64_t* mo_index_alpha);
qmckl_exit_code qmckl_set_determinant_mo_index_beta (const qmckl_context context, const int64_t* mo_index_beta);
qmckl_exit_code qmckl_set_determinant_mo_index_alpha (const qmckl_context context, const int64_t* mo_index_alpha, const int64_t size_max);
qmckl_exit_code qmckl_set_determinant_mo_index_beta (const qmckl_context context, const int64_t* mo_index_beta, const int64_t size_max);
#+end_src
#+NAME:pre2
@ -405,7 +405,7 @@ qmckl_exit_code qmckl_set_determinant_det_num_beta(qmckl_context context, const
<<post2>>
}
qmckl_exit_code qmckl_set_determinant_mo_index_alpha(qmckl_context context, const int64_t* mo_index_alpha) {
qmckl_exit_code qmckl_set_determinant_mo_index_alpha(qmckl_context context, const int64_t* mo_index_alpha, const int64_t size_max) {
<<pre2>>
int32_t mask = 1 << 3;
@ -430,6 +430,13 @@ qmckl_exit_code qmckl_set_determinant_mo_index_alpha(qmckl_context context, con
NULL);
}
if (size_max * sizeof(int64_t) < mem_info.size) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_3,
"qmckl_set_determinant_mo_index_alpha",
"input array too small");
}
memcpy(new_array, mo_index_alpha, mem_info.size);
ctx->det.mo_index_alpha = new_array;
@ -437,7 +444,7 @@ qmckl_exit_code qmckl_set_determinant_mo_index_alpha(qmckl_context context, con
<<post2>>
}
qmckl_exit_code qmckl_set_determinant_mo_index_beta(qmckl_context context, const int64_t* mo_index_beta) {
qmckl_exit_code qmckl_set_determinant_mo_index_beta(qmckl_context context, const int64_t* mo_index_beta, const int64_t size_max) {
<<pre2>>
int32_t mask = 1 << 4;
@ -462,6 +469,13 @@ qmckl_exit_code qmckl_set_determinant_mo_index_beta(qmckl_context context, cons
NULL);
}
if (size_max * sizeof(int64_t) < mem_info.size) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_3,
"qmckl_set_determinant_mo_index_beta",
"input array too small");
}
memcpy(new_array, mo_index_beta, mem_info.size);
ctx->det.mo_index_beta = new_array;