Revision: 53768
          http://brlcad.svn.sourceforge.net/brlcad/?rev=53768&view=rev
Author:   brlcad
Date:     2012-11-19 21:21:44 +0000 (Mon, 19 Nov 2012)
Log Message:
-----------
manually initialize instead of relying on calloc.  slightly faster alloc and 
probably slower albeit more explicit init.

Modified Paths:
--------------
    brlcad/trunk/src/libbu/bitv.c

Modified: brlcad/trunk/src/libbu/bitv.c
===================================================================
--- brlcad/trunk/src/libbu/bitv.c       2012-11-19 21:14:04 UTC (rev 53767)
+++ brlcad/trunk/src/libbu/bitv.c       2012-11-19 21:21:44 UTC (rev 53768)
@@ -81,16 +81,19 @@
 bu_bitv_new(unsigned int nbits)
 {
     struct bu_bitv *bv;
-    int bv_bytes;
-    int total_bytes;
+    size_t bv_bytes;
+    size_t total_bytes;
 
     bv_bytes = BU_BITS2BYTES(nbits);
     total_bytes = sizeof(struct bu_bitv) - 2*sizeof(bitv_t) + bv_bytes;
 
-    /* get zero'd memory, otherwise need to call BU_BITV_ZEROALL */
-    bv = (struct bu_bitv *)bu_calloc(1, (size_t)total_bytes, "struct bu_bitv");
-    BU_BITV_INIT(bv);
+    /* allocate bigger than struct, bits array extends past the end */
+    bv = (struct bu_bitv *)bu_malloc(total_bytes, "struct bu_bitv");
+
+    /* manually initialize */
+    BU_LIST_INIT_MAGIC(&(bv->l), BU_BITV_MAGIC);
     bv->nbits = bv_bytes * 8;
+    BU_BITV_ZEROALL(bv);
 
     return bv;
 }

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


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to