From aca5c9c5a6ab5183cd1174207e18f920e8bd32ea Mon Sep 17 00:00:00 2001 From: Armando Luiz Nicolini Delgado <nicolui@inf.ufpr.br> Date: Tue, 28 Jun 2022 12:13:54 -0300 Subject: [PATCH] =?UTF-8?q?/*=20corre=C3=A7=C3=A3o=20em=20coment=C3=A1rios?= =?UTF-8?q?=20em=20alocSisLin()=20*/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/sislin.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/sislin.c b/utils/sislin.c index c5a9287..75f649b 100644 --- a/utils/sislin.c +++ b/utils/sislin.c @@ -5,8 +5,7 @@ #include "utils.h" #include "sislin.h" -// Alocaçao de memória. Matriz como vetor de ponteiros para vetores -// alocados independentemente +// Alocaçao de matriz em memória. SistLinear_t* alocaSisLin (unsigned int n, tipoAloc_t tipo) { SistLinear_t *SL = (SistLinear_t *) malloc(sizeof(SistLinear_t)); @@ -22,7 +21,8 @@ SistLinear_t* alocaSisLin (unsigned int n, tipoAloc_t tipo) liberaSisLin(SL); return NULL; } - + + // Matriz como vetor de N ponteiros para um único vetor com N*N elementos if (tipo == pontVet) { SL->A[0] = (real_t *) malloc(n * n * sizeof(real_t)); if (!(SL->A[0])) { @@ -34,7 +34,9 @@ SistLinear_t* alocaSisLin (unsigned int n, tipoAloc_t tipo) SL->A[i] = SL->A[i-1]+n; } } - else if (tipo == pontPont) { + else if (tipo == pontPont) { // Matriz como vetor de N ponteiros + // para N vetores de N elementos cada + for (int i=0; i < n; ++i) SL->A[i] = (real_t *) malloc(n * sizeof(real_t)); } -- GitLab