Revision: 41868
http://brlcad.svn.sourceforge.net/brlcad/?rev=41868&view=rev
Author: starseeker
Date: 2010-12-30 19:19:22 +0000 (Thu, 30 Dec 2010)
Log Message:
-----------
Pull a few tweaks from cmake branch back to trunk - dem-g malloc cleanup,
dm-ogl and pl-dm tweaks, cmd.c change for MGED
Modified Paths:
--------------
brlcad/trunk/src/conv/dem-g.c
brlcad/trunk/src/mged/cmd.c
brlcad/trunk/src/mged/dm-ogl.c
brlcad/trunk/src/util/pl-dm.c
Modified: brlcad/trunk/src/conv/dem-g.c
===================================================================
--- brlcad/trunk/src/conv/dem-g.c 2010-12-30 19:14:45 UTC (rev 41867)
+++ brlcad/trunk/src/conv/dem-g.c 2010-12-30 19:19:22 UTC (rev 41868)
@@ -1563,31 +1563,32 @@
FILE *fp4;
long int offset = 0;
long int column = 0;
+ unsigned short int *buf3;
unsigned short int buf4 = 0;
- /* FIXME: C90 forbids variable size array declarations. use
bu_malloc/bu_free instead. */
- /* size of buf3 determined at run time */
- unsigned short int buf3[*in_ydim];
+ buf3 = bu_malloc(sizeof(unsigned short int) * (*in_ydim), "buf3");
if ((fp4=fopen(in_dsp_output_filename, "wb")) == NULL) {
bu_log("Could not open '%s' for write.\n", in_dsp_output_filename);
+ bu_free(buf3, "buf3");
return BRLCAD_ERROR;
}
for (offset = 0; offset <= *in_ydim-1; offset++) {
if ((fp3=fopen(in_temp_filename, "rb")) == NULL) {
bu_log("Could not open '%s' for read.\n", in_temp_filename);
fclose(fp4);
- return BRLCAD_ERROR;
+ bu_free(buf3, "buf3");
+ return BRLCAD_ERROR;
}
for (column = 1; column <= *in_xdim; column++) {
- fread(buf3, sizeof(buf3[0]), sizeof(buf3)/sizeof(buf3[0]), fp3);
- buf4 = buf3[offset];
+ fread(buf3, sizeof(unsigned short int), sizeof(unsigned short int)
* (*in_ydim)/sizeof(unsigned short int), fp3);
+ buf4 = *(buf3 + offset);
fwrite(&buf4, sizeof(buf4), 1, fp4);
}
fclose(fp3);
}
fclose(fp4);
-
+ bu_free(buf3, "buf3");
return BRLCAD_OK;
}
@@ -2079,12 +2080,16 @@
remove_whitespace(av[1]);
string_length = strlen(av[1]) + 5;
- /* FIXME: C90 forbids variable size array declarations. use
bu_malloc/bu_free instead. */
- char input_filename[string_length]; /* dem input file path and
file name */
- char temp_filename[string_length]; /* temp file path and file
name */
- char dsp_output_filename[string_length]; /* dsp output file path and
file name */
- char model_output_filename[string_length]; /* model output file path and
file name */
+ char *input_filename;
+ char *temp_filename;
+ char *dsp_output_filename;
+ char *model_output_filename;
+ input_filename = bu_malloc(sizeof(char *) * string_length,
"input_filename");
+ temp_filename = bu_malloc(sizeof(char *) * string_length, "temp_filename");
+ dsp_output_filename = bu_malloc(sizeof(char *) * string_length,
"dsp_output_filename");
+ model_output_filename = bu_malloc(sizeof(char *) * string_length,
"model_output_filename");
+
tmp_ptr = strcpy(input_filename, av[1]);
tmp_ptr = strcpy(temp_filename, input_filename);
tmp_ptr = strcat(temp_filename, ".tmp");
@@ -2116,10 +2121,18 @@
&x_cell_size,
&y_cell_size,
&unit_elevation) == BRLCAD_ERROR) {
+ bu_free(input_filename, "input_filename");
+ bu_free(temp_filename, "temp_filename");
+ bu_free(dsp_output_filename, "dsp_output_filename");
+ bu_free(model_output_filename, "model_output_filename");
bu_exit(BRLCAD_ERROR, "Error occured within function 'read_dem'.
Import can not continue.\n");
}
if (convert_load_order(temp_filename, dsp_output_filename, &xdim, &ydim)
== BRLCAD_ERROR) {
+ bu_free(input_filename, "input_filename");
+ bu_free(temp_filename, "temp_filename");
+ bu_free(dsp_output_filename, "dsp_output_filename");
+ bu_free(model_output_filename, "model_output_filename");
bu_exit(BRLCAD_ERROR, "Error occured within function
'convert_load_order'. Import can not continue.\n");
}
@@ -2132,9 +2145,16 @@
&x_cell_size,
&y_cell_size,
&unit_elevation) == BRLCAD_ERROR) {
+ bu_free(input_filename, "input_filename");
+ bu_free(temp_filename, "temp_filename");
+ bu_free(dsp_output_filename, "dsp_output_filename");
+ bu_free(model_output_filename, "model_output_filename");
bu_exit(BRLCAD_ERROR, "Error occured within function 'create_model'.
Model creation can not continue.\n");
}
-
+ bu_free(input_filename, "input_filename");
+ bu_free(temp_filename, "temp_filename");
+ bu_free(dsp_output_filename, "dsp_output_filename");
+ bu_free(model_output_filename, "model_output_filename");
return 0;
}
Modified: brlcad/trunk/src/mged/cmd.c
===================================================================
--- brlcad/trunk/src/mged/cmd.c 2010-12-30 19:14:45 UTC (rev 41867)
+++ brlcad/trunk/src/mged/cmd.c 2010-12-30 19:19:22 UTC (rev 41868)
@@ -2065,26 +2065,32 @@
/* XXX needs to be provided from points header */
extern int parse_point_file(ClientData clientData, Tcl_Interp *interpreter,
int argc, const char *argv[]);
+#ifndef BC_WITH_PARSERS
+int
+cmd_parse_points(ClientData UNUSED(clientData),
+ Tcl_Interp *UNUSED(interpreter),
+ int UNUSED(argc),
+ const char *UNUSED(argv[]))
+{
+ bu_log("parse_points was disabled in this compilation of mged due to
system limitations\n");
+ return TCL_ERROR;
+}
+#else
int
cmd_parse_points(ClientData clientData,
Tcl_Interp *interpreter,
int argc,
const char *argv[])
{
-
-#ifndef BC_WITH_PARSERS
- bu_log("parse_points was disabled in this compilation of mged due to
system limitations\n");
- return TCL_ERROR;
-#else
- if (argc != 2) {
+ if (argc != 2) {
bu_log("parse_points only supports a single file name right now\n");
bu_log("doing nothing\n");
return TCL_ERROR;
}
return parse_point_file(clientData, interpreter, argc-1, &(argv[1]));
+}
#endif
-}
int
Modified: brlcad/trunk/src/mged/dm-ogl.c
===================================================================
--- brlcad/trunk/src/mged/dm-ogl.c 2010-12-30 19:14:45 UTC (rev 41867)
+++ brlcad/trunk/src/mged/dm-ogl.c 2010-12-30 19:19:22 UTC (rev 41868)
@@ -72,7 +72,7 @@
static void do_fogHint();
struct bu_structparse Ogl_vparse[] = {
- {"%d", 1, "depthcue", Ogl_MV_O(cueing_on), Ogl_colorchange
},
+ {"%d", 1, "depthcue", Ogl_MV_O(cueing_on), Ogl_colorchange
},
{"%d", 1, "zclip", Ogl_MV_O(zclipping_on), zclip_hook },
{"%d", 1, "zbuffer", Ogl_MV_O(zbuffer_on),
establish_zbuffer },
{"%d", 1, "lighting", Ogl_MV_O(lighting_on),
establish_lighting },
@@ -93,7 +93,7 @@
int
Ogl_dm_init(struct dm_list *o_dm_list,
int argc,
- char *argv[])
+ const char *argv[])
{
struct bu_vls vls;
Modified: brlcad/trunk/src/util/pl-dm.c
===================================================================
--- brlcad/trunk/src/util/pl-dm.c 2010-12-30 19:14:45 UTC (rev 41867)
+++ brlcad/trunk/src/util/pl-dm.c 2010-12-30 19:19:22 UTC (rev 41868)
@@ -1064,7 +1064,7 @@
X_dmInit()
{
int windowbounds[6] = { 2047, -2048, 2047, -2048, 2047, -2048 };
- char *av[4];
+ const char *av[4];
av[0] = "X_open";
av[1] = "-i";
@@ -1097,7 +1097,7 @@
av[2] = "sampler_bind_dm";
av[3] = (char *)NULL;
- if ((dmp = DM_OPEN(INTERP, DM_TYPE_OGL, 3, av)) == DM_NULL) {
+ if ((dmp = DM_OPEN(INTERP, DM_TYPE_OGL, 3, (const char **)av)) == DM_NULL)
{
Tcl_AppendResult(INTERP, "Failed to open a display manager\n", (char
*)NULL);
return TCL_ERROR;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits