Bläddra i källkod

structure: CAvl: add assertion against count overflow

ambrop7 13 år sedan
förälder
incheckning
8c1df4f007
1 ändrade filer med 4 tillägg och 0 borttagningar
  1. 4 0
      structure/CAvl_impl.h

+ 4 - 0
structure/CAvl_impl.h

@@ -428,6 +428,9 @@ static void CAvl_Init (CAvl *o)
 static int CAvl_Insert (CAvl *o, CAvlArg arg, CAvlRef node, CAvlRef *out_ref)
 {
     ASSERT(node.link != CAvl_nulllink())
+#if CAVL_PARAM_FEATURE_COUNTS
+    ASSERT(CAvl_Count(o, arg) < CAVL_PARAM_VALUE_COUNT_MAX)
+#endif
     
     // insert to root?
     if (o->root == CAvl_nulllink()) {
@@ -500,6 +503,7 @@ static void CAvl_InsertAt (CAvl *o, CAvlArg arg, CAvlRef node, CAvlCount index)
 {
     ASSERT(node.link != CAvl_nulllink())
     ASSERT(index <= CAvl_Count(o, arg))
+    ASSERT(CAvl_Count(o, arg) < CAVL_PARAM_VALUE_COUNT_MAX)
     
     // insert to root?
     if (o->root == CAvl_nulllink()) {