From 2274f0d3058664dea677b148837cd68b76084091 Mon Sep 17 00:00:00 2001 From: Sebastian Buchwald Date: Tue, 7 Oct 2008 11:50:14 +0000 Subject: [PATCH] Added assertions to prevent unexpected results after PBQP element addition. [r22565] --- vector.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vector.c b/vector.c index 4f8ce17ee..d0465de0c 100644 --- a/vector.c +++ b/vector.c @@ -9,7 +9,13 @@ num pbqp_add(num x, num y) { if (x == INF_COSTS || y == INF_COSTS) return INF_COSTS; - return x + y; + num res = x + y; + + assert(res >= x); + assert(res >= y); + assert(res < INF_COSTS); + + return res; } vector *vector_alloc(pbqp *pbqp, unsigned length) -- 2.20.1