Revision: 41369
http://brlcad.svn.sourceforge.net/brlcad/?rev=41369&view=rev
Author: brlcad
Date: 2010-11-16 02:07:30 +0000 (Tue, 16 Nov 2010)
Log Message:
-----------
eliminate the MAXARGS fixed array size, replacing with dynamic memory
allocation exactly sized to the amount of memory we need. clean up the
_WIN32/non-_WIN32 sectioned logic too to reduce duplication.
Modified Paths:
--------------
brlcad/trunk/src/libged/rtcheck.c
Modified: brlcad/trunk/src/libged/rtcheck.c
===================================================================
--- brlcad/trunk/src/libged/rtcheck.c 2010-11-16 01:55:44 UTC (rev 41368)
+++ brlcad/trunk/src/libged/rtcheck.c 2010-11-16 02:07:30 UTC (rev 41369)
@@ -116,6 +116,7 @@
const char *bin;
char rtcheck[256] = {0};
+ size_t args = 0;
GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
GED_CHECK_DRAWABLE(gedp, GED_ERROR);
@@ -134,13 +135,24 @@
#endif
}
-#ifndef _WIN32
+ args = argc + 7 + 2 + ged_count_tops(gedp);
+ gedp->ged_gdp->gd_rt_cmd = (char **)bu_calloc(args, sizeof(char *), "alloc
gd_rt_cmd");
+
vp = &gedp->ged_gdp->gd_rt_cmd[0];
*vp++ = rtcheck;
*vp++ = "-M";
for (i=1; i < argc; i++)
*vp++ = (char *)argv[i];
+
+#ifndef _WIN32
*vp++ = gedp->ged_wdbp->dbip->dbi_filename;
+#else
+ {
+ char buf[512];
+ snprintf(buf, 512, "\"%s\"", gedp->ged_wdbp->dbip->dbi_filename);
+ *vp++ = buf;
+ }
+#endif
/*
* Now that we've grabbed all the options, if no args remain,
@@ -149,9 +161,7 @@
*/
if (i == argc) {
gedp->ged_gdp->gd_rt_cmd_len = vp - gedp->ged_gdp->gd_rt_cmd;
- gedp->ged_gdp->gd_rt_cmd_len += ged_build_tops(gedp,
- vp,
-
&gedp->ged_gdp->gd_rt_cmd[MAXARGS]);
+ gedp->ged_gdp->gd_rt_cmd_len += ged_build_tops(gedp, vp,
&gedp->ged_gdp->gd_rt_cmd[args]);
} else {
while (i < argc)
*vp++ = (char *)argv[i++];
@@ -163,6 +173,8 @@
Tcl_AppendResult(brlcad_interp, "\n", (char *)NULL);
}
+#ifndef _WIN32
+
(void)pipe(i_pipe);
(void)pipe(o_pipe);
(void)pipe(e_pipe);
@@ -229,44 +241,9 @@
ged_rtcheck_output_handler,
(ClientData)rtcop);
- return GED_OK;
#else
/* _WIN32 */
- vp = &gedp->ged_gdp->gd_rt_cmd[0];
- *vp++ = rtcheck;
- *vp++ = "-M";
- for (i=1; i < argc; i++)
- *vp++ = (char *)argv[i];
- {
- char buf[512];
-
- snprintf(buf, 512, "\"%s\"", gedp->ged_wdbp->dbip->dbi_filename);
- *vp++ = buf;
- }
-
- /*
- * Now that we've grabbed all the options, if no args remain,
- * append the names of all stuff currently displayed.
- * Otherwise, simply append the remaining args.
- */
- if (i == argc) {
- gedp->ged_gdp->gd_rt_cmd_len = vp - gedp->ged_gdp->gd_rt_cmd;
- gedp->ged_gdp->gd_rt_cmd_len += ged_build_tops(gedp,
- vp,
-
&gedp->ged_gdp->gd_rt_cmd[MAXARGS]);
- } else {
- while (i < argc)
- *vp++ = (char *)argv[i++];
- *vp = 0;
- vp = &gedp->ged_gdp->gd_rt_cmd[0];
- while (*vp)
- Tcl_AppendResult(brlcad_interp, *vp++, " ", (char *)NULL);
-
- Tcl_AppendResult(brlcad_interp, "\n", (char *)NULL);
- }
-
-
memset((void *)&si, 0, sizeof(STARTUPINFO));
memset((void *)&pi, 0, sizeof(PROCESS_INFORMATION));
memset((void *)&sa, 0, sizeof(SECURITY_ATTRIBUTES));
@@ -370,8 +347,12 @@
TCL_READABLE,
ged_rtcheck_output_handler,
(ClientData)rtcop);
- return GED_OK;
#endif
+
+ bu_free(gedp->ged_gdp->gd_rt_cmd, "free gd_rt_cmd");
+ gedp->ged_gdp->gd_rt_cmd = NULL;
+
+ return GED_OK;
}
#ifndef _WIN32
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits