From 6f609709f0de4dad24c7926650adfc29dbe244b9 Mon Sep 17 00:00:00 2001 From: "Kurt A. O'Hearn" <ohearnku@cse.msu.edu> Date: Tue, 26 Jan 2016 13:41:45 -0500 Subject: [PATCH] Fix bug with row pointer in sparse matrix data type. --- puremd_rc_1003/sPuReMD/allocate.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/puremd_rc_1003/sPuReMD/allocate.c b/puremd_rc_1003/sPuReMD/allocate.c index bb3fccf9..c9e8e1d9 100644 --- a/puremd_rc_1003/sPuReMD/allocate.c +++ b/puremd_rc_1003/sPuReMD/allocate.c @@ -43,16 +43,27 @@ int Allocate_Matrix( sparse_matrix **pH, int n, int m ) sparse_matrix *H; if( (*pH = (sparse_matrix*) malloc(sizeof(sparse_matrix))) == NULL ) + { return 0; + } H = *pH; H->n = n; H->m = m; - if( (H->start = (int*) malloc(sizeof(int) * n+1)) == NULL ) + if( (H->start = (int*) malloc(sizeof(int) * (n+1))) == NULL ) + { return 0; + } if( (H->entries = - (sparse_matrix_entry*) malloc(sizeof(sparse_matrix_entry)*m)) == NULL ) + (sparse_matrix_entry*) malloc(sizeof(sparse_matrix_entry)*m)) == NULL ) + { return 0; + } +// if( ((H->j = (int*) malloc(sizeof(int)*m)) == NULL) || +// ((H->val = (real*) malloc(sizeof(real)*m)) == NULL) ) +// { +// return 0; +// } return 1; } -- GitLab