Revision: 45742
          http://brlcad.svn.sourceforge.net/brlcad/?rev=45742&view=rev
Author:   bhinesley
Date:     2011-08-01 17:37:36 +0000 (Mon, 01 Aug 2011)

Log Message:
-----------
Compiler warnings because of dynamically sized arrays based on runtime variable 
were resolved by allocating memory in r45741 (which was not subsequently being 
freed). Since these sizes are known at compile time, we can instead size the 
arrays using preprocessor macros. Also resolved, were 3 warnings about printf 
format specifiers; the pointers needed to be dereferenced.

Modified Paths:
--------------
    brlcad/trunk/src/libged/edit.c

Modified: brlcad/trunk/src/libged/edit.c
===================================================================
--- brlcad/trunk/src/libged/edit.c      2011-08-01 14:25:50 UTC (rev 45741)
+++ brlcad/trunk/src/libged/edit.c      2011-08-01 17:37:36 UTC (rev 45742)
@@ -1150,15 +1150,10 @@
 struct edit_arg *
 edit_rotate_get_next_arg_head(const union edit_cmd *const cmd)
 {
+#define EDIT_ROTATE_ARG_HEADS_LEN 8
     static int idx = 0;
-    const int len = 8;
-    struct edit_arg **arg_heads;
-#if 0
-    struct edit_arg *arg_heads[len];
-#endif
+    struct edit_arg *arg_heads[EDIT_ROTATE_ARG_HEADS_LEN];
 
-    arg_heads = (struct edit_arg **)bu_calloc(len, sizeof(struct edit_arg **), 
"arg_heads");
-
     arg_heads[0] = cmd->rotate.objects;
     arg_heads[1] = cmd->rotate.ref_axis.from;
     arg_heads[2] = cmd->rotate.ref_axis.to;
@@ -1168,7 +1163,8 @@
     arg_heads[6] = cmd->rotate.ref_angle.to;
     arg_heads[7] = (struct edit_arg *)NULL;
 
-    return edit_cmd_get_next_arg_head(arg_heads, len, &idx);
+    return edit_cmd_get_next_arg_head(arg_heads, EDIT_ROTATE_ARG_HEADS_LEN,
+                                     &idx);
 }
 
 /**
@@ -1240,14 +1236,10 @@
 struct edit_arg *
 edit_scale_get_next_arg_head(const union edit_cmd *const cmd)
 {
+#define EDIT_ROTATE_ARG_HEADS_LEN 8
     static int idx = 0;
-    const int len = 7;
-    struct edit_arg **arg_heads;
-#if 0
-    struct edit_arg *arg_heads[len];
-#endif
+    struct edit_arg *arg_heads[EDIT_ROTATE_ARG_HEADS_LEN];
 
-    arg_heads = (struct edit_arg **)bu_calloc(len, sizeof(struct edit_arg **), 
"arg_heads");
 
     arg_heads[0] = cmd->scale.objects;
     arg_heads[1] = cmd->scale.ref_scale.from;
@@ -1257,7 +1249,8 @@
     arg_heads[5] = cmd->scale.ref_factor.to;
     arg_heads[6] = (struct edit_arg *)NULL;
 
-    return edit_cmd_get_next_arg_head(arg_heads, len, &idx);
+    return edit_cmd_get_next_arg_head(arg_heads, EDIT_ROTATE_ARG_HEADS_LEN,
+                                     &idx);
 }
 
 /**
@@ -1391,21 +1384,17 @@
 struct edit_arg *
 edit_translate_get_next_arg_head(const union edit_cmd *const cmd)
 {
+#define EDIT_ROTATE_ARG_HEADS_LEN 8
+    struct edit_arg *arg_heads[EDIT_ROTATE_ARG_HEADS_LEN];
     static int idx = 0;
-    const int len = 4;
-    struct edit_arg **arg_heads;
-#if 0
-    struct edit_arg *arg_heads[len];
-#endif
 
-    arg_heads = (struct edit_arg **)bu_calloc(len, sizeof(struct edit_arg **), 
"arg_heads");
-
     arg_heads[0] = cmd->translate.objects;
     arg_heads[1] = cmd->translate.ref_vector.from;
     arg_heads[2] = cmd->translate.ref_vector.to;
     arg_heads[3] = (struct edit_arg *)NULL;
 
-    return edit_cmd_get_next_arg_head(arg_heads, len, &idx);
+    return edit_cmd_get_next_arg_head(arg_heads, EDIT_ROTATE_ARG_HEADS_LEN,
+                                     &idx);
 }
 
 /* 
@@ -1651,8 +1640,8 @@
        } else {
            if (noisy)
                bu_vls_printf(gedp->ged_result_str, "too many consecutive"
-                             " coordinates: %f %f %f %f ...", arg->vector[0],
-                             arg->vector[1], arg->vector[2], coord[0]);
+                             " coordinates: %f %f %f %f ...", *arg->vector[0],
+                             *arg->vector[1], *arg->vector[2], coord[0]);
            return GED_ERROR;
        }
     } else {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to