1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-09-27 03:51:09 +02:00

Check in malloc

This commit is contained in:
Anthony Scemama 2022-07-07 18:25:49 +02:00
parent cd6de216b8
commit 1b846de413
3 changed files with 88 additions and 67 deletions

View File

@ -132,6 +132,13 @@ qmckl_exit_code
qmckl_vector_free( qmckl_context context,
qmckl_vector* vector)
{
if (vector == NULL) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
"qmckl_vector_free",
"Null pointer");
}
/* Always true */
assert (vector->data != NULL);
@ -213,6 +220,13 @@ qmckl_exit_code
qmckl_matrix_free( qmckl_context context,
qmckl_matrix* matrix)
{
if (matrix == NULL) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
"qmckl_matrix_free",
"Null pointer");
}
/* Always true */
assert (matrix->data != NULL);
@ -307,6 +321,13 @@ qmckl_exit_code
qmckl_tensor_free( qmckl_context context,
qmckl_tensor* tensor)
{
if (tensor == NULL) {
return qmckl_failwith( context,
QMCKL_INVALID_ARG_2,
"qmckl_tensor_free",
"Null pointer");
}
/* Always true */
assert (tensor->data != NULL);

View File

@ -308,7 +308,7 @@ qmckl_set_point (qmckl_context context,
assert (ctx != NULL);
qmckl_exit_code rc;
if (ctx->point.num < num) {
if (ctx->point.num != num) {
if (ctx->point.coord.data != NULL) {
rc = qmckl_matrix_free(context, &(ctx->point.coord));

View File

@ -1086,7 +1086,7 @@ qmckl_trexio_read(const qmckl_context context, const char* file_name, const int6
qmckl_exit_code rc;
char file_name_new[size_max+1];
strncpy(file_name_new, file_name, size_max+1);
strncpy(file_name_new, file_name, size_max);
file_name_new[size_max] = '\0';
#ifdef HAVE_TREXIO