Revision: 41364
http://brlcad.svn.sourceforge.net/brlcad/?rev=41364&view=rev
Author: brlcad
Date: 2010-11-15 22:35:18 +0000 (Mon, 15 Nov 2010)
Log Message:
-----------
make 'path' directory array be dynamically allocated so we're not using
RT_MAXARGS. untested of course.
Modified Paths:
--------------
brlcad/trunk/src/libged/wcodes.c
Modified: brlcad/trunk/src/libged/wcodes.c
===================================================================
--- brlcad/trunk/src/libged/wcodes.c 2010-11-15 22:17:24 UTC (rev 41363)
+++ brlcad/trunk/src/libged/wcodes.c 2010-11-15 22:35:18 UTC (rev 41364)
@@ -41,15 +41,42 @@
#define ID_TABLE 3
-static struct directory *path[RT_MAXARGS];
+#define PATH_STEP 256
+static struct directory **path = NULL;
+static size_t path_capacity = 0;
-HIDDEN void wcodes_printnode(struct db_i *, struct rt_comb_internal *, union
tree *, genptr_t, genptr_t, genptr_t);
+HIDDEN int wcodes_printcodes(struct ged *gedp, FILE *fp, struct directory *dp,
size_t pathpos);
+
+HIDDEN void
+wcodes_printnode(struct db_i *dbip, struct rt_comb_internal *UNUSED(comb),
union tree *comb_leaf, genptr_t user_ptr1, genptr_t user_ptr2, genptr_t
user_ptr3)
+{
+ FILE *fp;
+ size_t *pathpos;
+ struct directory *nextdp;
+ struct ged *gedp;
+
+ RT_CK_DBI(dbip);
+ RT_CK_TREE(comb_leaf);
+
+ if ((nextdp=db_lookup(dbip, comb_leaf->tr_l.tl_name, LOOKUP_NOISY)) ==
DIR_NULL)
+ return;
+
+ fp = (FILE *)user_ptr1;
+ pathpos = (size_t *)user_ptr2;
+ gedp = (struct ged *)user_ptr3;
+
+ /* recurse on combinations */
+ if (nextdp->d_flags & DIR_COMB)
+ (void)wcodes_printcodes(gedp, fp, nextdp, (*pathpos)+1);
+}
+
+
HIDDEN int
-wcodes_printcodes(struct ged *gedp, FILE *fp, struct directory *dp, int
pathpos)
+wcodes_printcodes(struct ged *gedp, FILE *fp, struct directory *dp, size_t
pathpos)
{
- int i;
+ size_t i;
struct rt_db_internal intern;
struct rt_comb_internal *comb;
int id;
@@ -84,6 +111,10 @@
}
if (comb->tree) {
+ if (pathpos >= path_capacity) {
+ path_capacity += PATH_STEP;
+ path = bu_realloc(path, sizeof(struct directory *) * path_capacity,
"realloc path bigger");
+ }
path[pathpos] = dp;
db_tree_funcleaf(gedp->ged_wdbp->dbip, comb, comb->tree,
wcodes_printnode,
(genptr_t)fp, (genptr_t)&pathpos, (genptr_t)gedp);
@@ -94,30 +125,6 @@
}
-HIDDEN void
-wcodes_printnode(struct db_i *dbip, struct rt_comb_internal *UNUSED(comb),
union tree *comb_leaf, genptr_t user_ptr1, genptr_t user_ptr2, genptr_t
user_ptr3)
-{
- FILE *fp;
- int *pathpos;
- struct directory *nextdp;
- struct ged *gedp;
-
- RT_CK_DBI(dbip);
- RT_CK_TREE(comb_leaf);
-
- if ((nextdp=db_lookup(dbip, comb_leaf->tr_l.tl_name, LOOKUP_NOISY)) ==
DIR_NULL)
- return;
-
- fp = (FILE *)user_ptr1;
- pathpos = (int *)user_ptr2;
- gedp = (struct ged *)user_ptr3;
-
- /* recurse on combinations */
- if (nextdp->d_flags & DIR_COMB)
- (void)wcodes_printcodes(gedp, fp, nextdp, (*pathpos)+1);
-}
-
-
int
ged_wcodes(struct ged *gedp, int argc, const char *argv[])
{
@@ -150,6 +157,9 @@
return GED_ERROR;
}
+ path = bu_calloc(PATH_STEP, sizeof(struct directory *), "alloc initial
path");
+ path_capacity = PATH_STEP;
+
for (i = 2; i < argc; ++i) {
if ((dp = db_lookup(gedp->ged_wdbp->dbip, argv[i], LOOKUP_NOISY)) !=
DIR_NULL) {
status = wcodes_printcodes(gedp, fp, dp, 0);
@@ -162,6 +172,8 @@
}
(void)fclose(fp);
+ bu_free(path, "dealloc path");
+
return GED_OK;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits