Revision: 41314
http://brlcad.svn.sourceforge.net/brlcad/?rev=41314&view=rev
Author: brlcad
Date: 2010-11-10 19:23:29 +0000 (Wed, 10 Nov 2010)
Log Message:
-----------
eliminate the use of RT_MAXARGS by making oldTrees be a dynamically allocated
array. adding a capacity parameter to keep track of how many slots are
available. renamed oldNumTrees to just numTrees and used size_t for sizes.
Modified Paths:
--------------
brlcad/trunk/include/dm-rtgl.h
brlcad/trunk/src/libdm/dm-rtgl.c
Modified: brlcad/trunk/include/dm-rtgl.h
===================================================================
--- brlcad/trunk/include/dm-rtgl.h 2010-11-10 19:20:57 UTC (rev 41313)
+++ brlcad/trunk/include/dm-rtgl.h 2010-11-10 19:23:29 UTC (rev 41314)
@@ -136,12 +136,13 @@
int controlClip;
int calls;
int jobsDone;
- char *oldTrees[RT_MAXARGS];
- int oldNumTrees;
+ char **oldTrees;
+ size_t numTrees;
+ size_t treeCapacity;
struct bu_hash_tbl *colorTable;
struct ptInfoList *currItem;
struct jobList *currJob;
- int numJobs;
+ size_t numJobs;
int rtglWasClosed;
};
Modified: brlcad/trunk/src/libdm/dm-rtgl.c
===================================================================
--- brlcad/trunk/src/libdm/dm-rtgl.c 2010-11-10 19:20:57 UTC (rev 41313)
+++ brlcad/trunk/src/libdm/dm-rtgl.c 2010-11-10 19:23:29 UTC (rev 41314)
@@ -170,6 +170,7 @@
0,
NULL,
0,
+ 0,
NULL,
NULL,
NULL,
@@ -773,9 +774,15 @@
rtgljob.controlClip = 1;
rtgljob.calls = 0;
rtgljob.jobsDone = 0;
- rtgljob.oldNumTrees = 0;
+ rtgljob.numTrees = 0;
rtgljob.numJobs = 0;
rtgljob.rtglWasClosed = 1;
+
+ /* release trees */
+ if (rtgljob.oldTrees != NULL)
+ bu_free(rtgljob.oldTrees, "free oldTrees");
+ rtgljob.oldTrees = (char **)NULL;
+ rtgljob.treeCapacity = 0;
/* free draw list */
if (rtgljob.colorTable != NULL) {
@@ -786,11 +793,31 @@
rtgljob.currItem = NULL;
rtgljob.currJob = NULL;
-
-
return TCL_OK;
}
+
+/* stash a new job into a dynamically allocated container */
+HIDDEN void
+rtgl_stashTree(struct rtglJobs *job, char *tree)
+{
+ static const size_t STEP = 1024;
+
+ /* make sure there is enough room */
+ if (job->treeCapacity == 0) {
+ job->oldTrees = (char **)bu_calloc(STEP, sizeof(char *), "called
oldTrees");
+ job->treeCapacity = STEP;
+ } else if (job->numTrees + 1 >= job->treeCapacity) {
+ job->oldTrees = (char **)bu_realloc(job->oldTrees, (sizeof(char *) *
job->treeCapacity) + STEP, "realloc oldTrees");
+ job->treeCapacity += STEP;
+ }
+
+ /* add it */
+ job->oldTrees[job->numTrees] = tree;
+ job->numTrees++;
+}
+
+
/*
* O G L _ D R A W B E G I N
*
@@ -1611,7 +1638,7 @@
int foundalloldtrees = 1;
int foundthistree = 0;
- for (i = 0; i < rtgljob.oldNumTrees; i++) {
+ for (i = 0; i < rtgljob.numTrees; i++) {
currTree = rtgljob.oldTrees[i];
foundthistree = 0;
for (j = 0; j < numVisible; j++) {
@@ -1627,7 +1654,7 @@
foundalloldtrees = 1;
/* drop previous work */
- rtgljob.oldNumTrees = 0;
+ rtgljob.numTrees = 0;
freeJobList(&jobs);
if (rtgljob.colorTable != NULL) {
@@ -1651,7 +1678,7 @@
if (numVisible == 0) {
/* drop previous work */
- rtgljob.oldNumTrees = 0;
+ rtgljob.numTrees = 0;
freeJobList(&jobs);
if (rtgljob.colorTable != NULL) {
@@ -1682,7 +1709,7 @@
if (rtgljob.rtglWasClosed == 1) {
rtgljob.rtglWasClosed = 0;
- rtgljob.oldNumTrees = 0;
+ rtgljob.numTrees = 0;
/* drop previous work */
freeJobList(&jobs);
@@ -1717,7 +1744,7 @@
* but that's not set up yet without clearing everything
* first and starting over.
*/
- for (j = 0; j < rtgljob.oldNumTrees; j++) {
+ for (j = 0; j < rtgljob.numTrees; j++) {
if (strcmp(currTree, rtgljob.oldTrees[j]) == 0)
new = 0;
}
@@ -1729,7 +1756,7 @@
/* add new tree to list of displayed */
numNew++;
- rtgljob.oldTrees[rtgljob.oldNumTrees++] = currTree;
+ rtgl_stashTree(&rtgljob, currTree);
}
}
@@ -1750,7 +1777,7 @@
jobsArray = NULL;
}
maxSpan = 0.0;
- rtgljob.oldNumTrees = 0;
+ rtgljob.numTrees = 0;
numShot = rtgljob.numJobs = 0;
rtgljob.currJob = NULL;
numVisible = ged_build_tops(gedp, visibleTrees,
&visibleTrees[RT_MAXARGS]);
@@ -1763,7 +1790,7 @@
* but that's not set up yet without clearing everything
* first and starting over.
**/
- for (j = 0; j < rtgljob.oldNumTrees; j++) {
+ for (j = 0; j < rtgljob.numTrees; j++) {
if (strcmp(currTree, rtgljob.oldTrees[j]) == 0)
new = 0;
}
@@ -1775,7 +1802,7 @@
/* add new tree to list of displayed */
numNew++;
- rtgljob.oldTrees[rtgljob.oldNumTrees++] = currTree;
+ rtgl_stashTree(&rtgljob, currTree);
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits