Index: trunk/archive/pslib/src/Utils/trace.c
===================================================================
--- trunk/archive/pslib/src/Utils/trace.c	(revision 177)
+++ trunk/archive/pslib/src/Utils/trace.c	(revision 262)
@@ -134,7 +134,7 @@
      * No match; add cpt0 to this level. Ensure that subcomp is sorted
      */
-    if (comp->n == comp->dimen) {
+    if (comp->n >= comp->dimen - 1) {
 	comp->dimen += 5;
-	comp->subcomp = psRealloc(comp->subcomp, comp->dimen);
+	comp->subcomp = psRealloc(comp->subcomp, comp->dimen*sizeof(Component *));
     }
 
@@ -146,4 +146,5 @@
 		comp->subcomp[j] = comp->subcomp[j - 1];
 	    }
+	    break;
 	}
     }
@@ -300,45 +301,2 @@
     }
 }
-
-/*****************************************************************************/
-#if 0					// testing
-
-int main(void)
-{
-    psSetLogFormat("NM");		// suppress some of the psLogMsg verbosity
-    
-#if 0
-    psSetTraceLevel("", 10);
-#else
-    psSetTraceLevel("aaa.bbb.ccc.ddd", 9);
-    psSetTraceLevel("aaa.bbb.ccc", 3);
-    psSetTraceLevel("aaa.bbb.ddd", 4);
-    psSetTraceLevel("aaa.BBB", 2);
-    psSetTraceLevel("BBB", 2);
-    psSetTraceLevel("BBB.XXX.YYY.ZZZ", 5);
-    psSetTraceLevel("aaa.bbb", 2);
-    psSetTraceLevel("aaa.bbb.ccc", 9);
-    psSetTraceLevel("aaa", 1);
-#endif
-    
-    psPrintTraceLevels();
-    printf("\n");
-
-    psTrace("aaa.bbb.ddd", 2, "(aaa.bbb.ddd) Hello %s\n", "world");
-    psTrace("aaa", 2, "aaa\n");
-    psTrace("", 2, "\"\"\n");
-    psTrace("aaa.bbb", 2, "aaa.bbb\n");
-    psTrace("aaa.bbb.ddd", 2, "aaa.bbb.ddd\n");
-    psTrace("aaa.bbb.ddd", 4, "aaa.bbb.ddd\n");
-    psTrace("aaa.bbb.ddd", 2, "aaa.bbb.ddd\n");
-    psTrace("aaa.bbb.ccc", 1, "aaa.bbb.ccc\n");
-    psTrace("aaa.bbb.eee", 2, "aaa.bbb.eee\n");
-
-    psTraceReset();
-    fprintf(stderr,"Checking for memory leaks:\n");
-    psMemCheckLeaks(0, NULL, stderr);
-    
-
-    return 0;
-}
-#endif
