Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-10-05 00:11:54 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-10-05 00:11:54 +0400
commit2a08c0dc5620dd126da54f36a48402d34f83a00c (patch)
tree83f03dff544d3022195eb1d64625c4eb6bf8eaa1 /intern/opennl
parent592f80625bec2d31b22e3e309df9bb693eb967f3 (diff)
Code cleanup: fix some clang checker warnings.
Diffstat (limited to 'intern/opennl')
-rw-r--r--intern/opennl/intern/opennl.c15
-rw-r--r--intern/opennl/superlu/get_perm_c.c52
2 files changed, 37 insertions, 30 deletions
diff --git a/intern/opennl/intern/opennl.c b/intern/opennl/intern/opennl.c
index 71809cc7480..f9c63e9ecf6 100644
--- a/intern/opennl/intern/opennl.c
+++ b/intern/opennl/intern/opennl.c
@@ -137,14 +137,14 @@ static void __nl_should_not_have_reached(char* file, int line) {
/************************************************************************************/
/* memory management */
-#define __NL_NEW(T) (T*)(calloc(1, sizeof(T)))
-#define __NL_NEW_ARRAY(T,NB) (T*)(calloc((NB),sizeof(T)))
+#define __NL_NEW(T) (T*)(calloc(1, sizeof(T)))
+#define __NL_NEW_ARRAY(T,NB) (T*)(calloc(MAX(NB, 1),sizeof(T)))
#define __NL_RENEW_ARRAY(T,x,NB) (T*)(realloc(x,(NB)*sizeof(T)))
-#define __NL_DELETE(x) free(x); x = NULL
-#define __NL_DELETE_ARRAY(x) free(x); x = NULL
+#define __NL_DELETE(x) if(x) free(x); x = NULL
+#define __NL_DELETE_ARRAY(x) if(x) free(x); x = NULL
-#define __NL_CLEAR(T, x) memset(x, 0, sizeof(T))
-#define __NL_CLEAR_ARRAY(T,x,NB) memset(x, 0, (NB)*sizeof(T))
+#define __NL_CLEAR(T, x) memset(x, 0, sizeof(T))
+#define __NL_CLEAR_ARRAY(T,x,NB) if(NB) memset(x, 0, (NB)*sizeof(T))
/************************************************************************************/
/* Dynamic arrays for sparse row/columns */
@@ -1042,6 +1042,9 @@ static NLboolean __nlFactorize_SUPERLU(__NLContext *context, NLint *permutation)
NLuint n = context->n;
NLuint nnz = __nlSparseMatrixNNZ(M); /* number of non-zero coeffs */
+ /*if(n > 10)
+ n = 10;*/
+
/* Compressed Row Storage matrix representation */
NLint *xa = __NL_NEW_ARRAY(NLint, n+1);
NLfloat *rhs = __NL_NEW_ARRAY(NLfloat, n);
diff --git a/intern/opennl/superlu/get_perm_c.c b/intern/opennl/superlu/get_perm_c.c
index 320fe3471f4..59889645988 100644
--- a/intern/opennl/superlu/get_perm_c.c
+++ b/intern/opennl/superlu/get_perm_c.c
@@ -173,17 +173,19 @@ getata(
/* Flag the diagonal so it's not included in the B matrix */
marker[j] = j;
- for (i = colptr[j]; i < colptr[j+1]; ++i) {
- /* A_kj is nonzero, add pattern of column T_*k to B_*j */
- k = rowind[i];
- for (ti = t_colptr[k]; ti < t_colptr[k+1]; ++ti) {
- trow = t_rowind[ti];
- if ( marker[trow] != j ) {
- marker[trow] = j;
- b_rowind[num_nz++] = trow;
+ if ( *atanz ) {
+ for (i = colptr[j]; i < colptr[j+1]; ++i) {
+ /* A_kj is nonzero, add pattern of column T_*k to B_*j */
+ k = rowind[i];
+ for (ti = t_colptr[k]; ti < t_colptr[k+1]; ++ti) {
+ trow = t_rowind[ti];
+ if ( marker[trow] != j ) {
+ marker[trow] = j;
+ b_rowind[num_nz++] = trow;
+ }
+ }
+ }
}
- }
- }
}
b_colptr[n] = num_nz;
@@ -305,21 +307,23 @@ at_plus_a(
marker[j] = j;
/* Add pattern of column A_*k to B_*j */
- for (i = colptr[j]; i < colptr[j+1]; ++i) {
- k = rowind[i];
- if ( marker[k] != j ) {
- marker[k] = j;
- (*b_rowind)[num_nz++] = k;
- }
- }
+ if (*bnz) {
+ for (i = colptr[j]; i < colptr[j+1]; ++i) {
+ k = rowind[i];
+ if ( marker[k] != j ) {
+ marker[k] = j;
+ (*b_rowind)[num_nz++] = k;
+ }
+ }
- /* Add pattern of column T_*k to B_*j */
- for (i = t_colptr[j]; i < t_colptr[j+1]; ++i) {
- k = t_rowind[i];
- if ( marker[k] != j ) {
- marker[k] = j;
- (*b_rowind)[num_nz++] = k;
- }
+ /* Add pattern of column T_*k to B_*j */
+ for (i = t_colptr[j]; i < t_colptr[j+1]; ++i) {
+ k = t_rowind[i];
+ if ( marker[k] != j ) {
+ marker[k] = j;
+ (*b_rowind)[num_nz++] = k;
+ }
+ }
}
}
(*b_colptr)[n] = num_nz;