Commit 6db46a9e authored by Sebastien Timmermans's avatar Sebastien Timmermans 🎹

[Fix] removing a warning in readmatrix scanf + handle nquch vector allocation and free in equil

parent 7ed6c2a3
Pipeline #4422 passed with stage
in 9 minutes and 35 seconds
......@@ -21,6 +21,7 @@
#include "mbs_linalg.h"
#include "mbs_message.h"
#include "nrfct.h"
#include "useful_functions.h"
#define MAX_NB_BUFFER (3 + 1) // maximal number of buffer 3 for equilibrium, 1 for q (animation)
......@@ -121,7 +122,7 @@ void mbs_delete_equil(MbsEquil* eq, MbsData* mbs_data)
if (eq->options->nquch != 0)
{
free(eq->options->xch_ptr);
free(eq->options->quch);
free_ivec_0(eq->options->quch);
free(eq->xch);
} // corresponding to malloc in mbs_equil_exchange
if (eq->options->nxe != 0)
......@@ -542,7 +543,7 @@ void mbs_equil_finish(MbsEquil* eq, MbsData* s)
void mbs_equil_exchange(MbsEquilOptions *options)
{
int i;
options->quch = (int*)malloc((options->nquch + 1) *sizeof(int));
options->quch = get_ivec_0(options->nquch+1);
options->xch_ptr = (double**)malloc((options->nquch + 1) *sizeof(double*));
for (i = 0; i <= options->nquch; i++)
......@@ -1036,7 +1037,15 @@ void mbs_print_equil(MbsEquil* eq)
}
mbs_msg(" nquch . . . . = %d \n", eq->options->nquch);
mbs_msg("quch = "); print_ivec_1(eq->options->quch);
if (eq->options->nquch != 0)
{
mbs_msg("quch = "); print_ivec_0(eq->options->quch, eq->options->nquch + 1);
}
else
{
mbs_msg("quch = [] \n");
}
mbs_msg(" nxe . . . . = %d \n", eq->options->nxe);
mbs_msg("Variables \n");
......
......@@ -962,19 +962,19 @@ void zeros_dmat_0(double **mat, int x, int y)
void readmatrix(double** mat, int* n)
{
int i, j;
int err = 0;
mbs_msg("\tEnter the no: rows in the matrix : ");
scanf("%d", &n[0]);
err = scanf("%d", &n[0]);
mbs_msg("\tEnter the no: columns in the matrix : ");
scanf("%d", &n[1]);
err = scanf("%d", &n[1]);
mbs_msg("\tEnter The Matrix Elements Row wise ");
scanf("\n");
err = scanf("\n");
for (i = 0; i < n[0]; ++i)
{
for (j = 0; j < n[1]; ++j)
{
scanf("%lf", &mat[i][j]);
err = scanf("%lf", &mat[i][j]);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment