BigJ realloc (#623)
This PR fixes reallocation issues with CSR BigJ arrays.
This commit is contained in:
parent
76b8adc21a
commit
db1364a392
@ -165,7 +165,9 @@ hypre_CSRMatrixInitialize( hypre_CSRMatrix *matrix )
|
||||
*--------------------------------------------------------------------------*/
|
||||
|
||||
HYPRE_Int
|
||||
hypre_CSRMatrixResize( hypre_CSRMatrix *matrix, HYPRE_Int new_num_rows, HYPRE_Int new_num_cols,
|
||||
hypre_CSRMatrixResize( hypre_CSRMatrix *matrix,
|
||||
HYPRE_Int new_num_rows,
|
||||
HYPRE_Int new_num_cols,
|
||||
HYPRE_Int new_num_nonzeros )
|
||||
{
|
||||
HYPRE_MemoryLocation memory_location = hypre_CSRMatrixMemoryLocation(matrix);
|
||||
@ -191,10 +193,17 @@ hypre_CSRMatrixResize( hypre_CSRMatrix *matrix, HYPRE_Int new_num_rows, HYPRE_In
|
||||
}
|
||||
else
|
||||
{
|
||||
hypre_CSRMatrixData(matrix) = hypre_TReAlloc_v2(hypre_CSRMatrixData(matrix), HYPRE_Complex,
|
||||
old_num_nonzeros, HYPRE_Complex, new_num_nonzeros, memory_location);
|
||||
hypre_CSRMatrixData(matrix) = hypre_TReAlloc_v2(hypre_CSRMatrixData(matrix), HYPRE_Complex, old_num_nonzeros,
|
||||
HYPRE_Complex, new_num_nonzeros, memory_location);
|
||||
}
|
||||
|
||||
if (hypre_CSRMatrixBigJ(matrix))
|
||||
{
|
||||
hypre_CSRMatrixBigJ(matrix) = hypre_TReAlloc_v2(hypre_CSRMatrixBigJ(matrix), HYPRE_BigInt, old_num_nonzeros,
|
||||
HYPRE_BigInt, new_num_nonzeros, memory_location);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!hypre_CSRMatrixJ(matrix))
|
||||
{
|
||||
hypre_CSRMatrixJ(matrix) = hypre_CTAlloc(HYPRE_Int, new_num_nonzeros, memory_location);
|
||||
@ -205,6 +214,7 @@ hypre_CSRMatrixResize( hypre_CSRMatrix *matrix, HYPRE_Int new_num_rows, HYPRE_In
|
||||
HYPRE_Int, new_num_nonzeros, memory_location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (new_num_rows != hypre_CSRMatrixNumRows(matrix))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user