Revision: 47093
          http://brlcad.svn.sourceforge.net/brlcad/?rev=47093&view=rev
Author:   abhi2011
Date:     2011-10-05 13:20:40 +0000 (Wed, 05 Oct 2011)
Log Message:
-----------
Corrected some code related to prefixing names

Modified Paths:
--------------
    brlcad/trunk/src/libged/simulate/simulate.c
    brlcad/trunk/src/libged/simulate/simutils.c
    brlcad/trunk/src/libged/simulate/simutils.h

Modified: brlcad/trunk/src/libged/simulate/simulate.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simulate.c 2011-10-05 12:26:14 UTC (rev 
47092)
+++ brlcad/trunk/src/libged/simulate/simulate.c 2011-10-05 13:20:40 UTC (rev 
47093)
@@ -84,7 +84,9 @@
     size_t prefix_len, prefixed_name_len;
     int i;
     struct rigid_body *prev_node = NULL, *current_node;
+    struct bu_vls dp_name_vls = BU_VLS_INIT_ZERO;
 
+
     /* Kill the existing sim comb */
     kill(gedp, sim_params->sim_comb_name);
     sim_params->num_bodies = 0;
@@ -104,11 +106,8 @@
            }
 
            /* Duplicate the region */
-           prefix_len = strlen(prefix);
-           prefixed_name_len = strlen(prefix)+strlen(dp->d_namep)+1;
-           prefixed_name = (char *)bu_malloc(prefixed_name_len, "Adding sim_ 
prefix");
-           bu_strlcpy(prefixed_name, prefix, prefix_len + 1);
-           bu_strlcat(prefixed_name + prefix_len, dp->d_namep, 
prefixed_name_len - prefix_len);
+           bu_vls_sprintf(&dp_name_vls, "%s%s", prefix, dp->d_namep);
+           prefixed_name = bu_vls_addr(&dp_name_vls);
 
            kill_copy(gedp, dp, prefixed_name);
            bu_vls_printf(gedp->ged_result_str, "add_regions: Copied \"%s\" to 
\"%s\"\n", dp->d_namep, prefixed_name);

Modified: brlcad/trunk/src/libged/simulate/simutils.c
===================================================================
--- brlcad/trunk/src/libged/simulate/simutils.c 2011-10-05 12:26:14 UTC (rev 
47092)
+++ brlcad/trunk/src/libged/simulate/simutils.c 2011-10-05 13:20:40 UTC (rev 
47093)
@@ -115,23 +115,6 @@
 }
 
 
-char*
-prefix_name(char *prefix, char *original)
-{
-    /* Prepare prefixed bounding box primitive name */
-    size_t prefix_len, prefixed_name_len;
-    char *prefixed_name;
-
-    prefix_len = strlen(prefix);
-    prefixed_name_len = strlen(prefix)+strlen(original) + 1;
-    prefixed_name = (char *)bu_malloc(prefixed_name_len, "Adding prefix");
-    bu_strlcpy(prefixed_name, prefix, prefix_len + 1);
-    bu_strlcat(prefixed_name + prefix_len, original,
-              prefixed_name_len - prefix_len);
-    return prefixed_name;
-}
-
-
 int
 kill(struct ged *gedp, char *name)
 {
@@ -342,6 +325,16 @@
 }
 
 
+char*
+prefix_name(char *prefix, char *name)
+{
+       struct bu_vls buffer_vls = BU_VLS_INIT_ZERO;
+       bu_vls_sprintf(&buffer_vls, "%s%s", prefix, name);
+
+       return bu_vls_addr(&buffer_vls);
+}
+
+
 int
 apply_color(struct ged *gedp,
            char* name,

Modified: brlcad/trunk/src/libged/simulate/simutils.h
===================================================================
--- brlcad/trunk/src/libged/simulate/simutils.h 2011-10-05 12:26:14 UTC (rev 
47092)
+++ brlcad/trunk/src/libged/simulate/simutils.h 2011-10-05 13:20:40 UTC (rev 
47093)
@@ -78,12 +78,10 @@
 
 
 /**
- * Used to prefix a name, requires memory to be freed by caller
- * TODO: Get rid of this, replace all calls to this with bu_vls
- * and prefix using bu functions
+ * Prefixes name with prefix and returns the combined string
  */
 char*
-prefix_name(char *prefix, char *original);
+prefix_name(char *prefix, char *name);
 
 
 /**

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


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to