Introduction
Introduction Statistics Contact Development Disclaimer Help
tgrain.c: fail if number of contacts exceed MAXCONTACTS - granular - granular d…
git clone git://src.adamsgaard.dk/granular
Log
Files
Refs
README
LICENSE
---
commit 6bfe4343c4a35003808fb1b3bdf94480a7c7d216
parent 4c0f7cd6f3bc47dd2c33141ef0a3da3f9b25f957
Author: Anders Damsgaard <[email protected]>
Date: Wed, 21 Apr 2021 10:18:14 +0200
grain.c: fail if number of contacts exceed MAXCONTACTS
Diffstat:
M grain.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/grain.c b/grain.c
t@@ -322,7 +322,7 @@ grain_register_contact(struct grain *g, size_t i, size_t j,
int ic, d;
/* first pass: check if contact is already registered */
- for (ic = 0; ic <= MAXCONTACTS; ic++)
+ for (ic = 0; ic < MAXCONTACTS; ic++)
if (g->contacts[ic].j == j) {
g->contacts[ic].overlap = overlap;
for (d = 0; d < 3; d++)
t@@ -332,7 +332,10 @@ grain_register_contact(struct grain *g, size_t i, size_t …
/* second pass: register as new contact if overlapping */
if (overlap < 0.0)
- for (ic = 0; ic <= MAXCONTACTS; ic++)
+ for (ic = 0; ic <= MAXCONTACTS; ic++) {
+ if (ic == MAXCONTACTS)
+ err(1, "%s: contact %zu exceeds MAXCONTACTS (%…
+ __func__, i, MAXCONTACTS);
if (!g->contacts[ic].active) {
contact_new(&g->contacts[ic], i, j);
g->ncontacts += 1;
t@@ -342,4 +345,5 @@ grain_register_contact(struct grain *g, size_t i, size_t j,
g->contacts[ic].tandisp[d] = 0.0;
}
}
+ }
}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.