Revision: 53764
          http://brlcad.svn.sourceforge.net/brlcad/?rev=53764&view=rev
Author:   brlcad
Date:     2012-11-19 21:01:52 +0000 (Mon, 19 Nov 2012)
Log Message:
-----------
document the function and allow for a null resource pointer

Modified Paths:
--------------
    brlcad/trunk/src/librt/prep.c

Modified: brlcad/trunk/src/librt/prep.c
===================================================================
--- brlcad/trunk/src/librt/prep.c       2012-11-19 20:52:24 UTC (rev 53763)
+++ brlcad/trunk/src/librt/prep.c       2012-11-19 21:01:52 UTC (rev 53764)
@@ -832,19 +832,25 @@
 }
 
 
+/**
+ * returns a bitv zero-initialized with space for least nbits back to
+ * the caller.  if a resource pointer is provided, a previously
+ * allocated bitv may be reused or a new one will be allocated.
+ */
 struct bu_bitv *
 rt_get_solidbitv(size_t nbits, struct resource *resp)
 {
     struct bu_bitv *solidbits;
     int counter=0;
 
-    if (resp->re_solid_bitv.magic != BU_LIST_HEAD_MAGIC) {
+    if (resp && resp->re_solid_bitv.magic != BU_LIST_HEAD_MAGIC) {
        bu_bomb("Bad magic number in re_solid_btiv list\n");
     }
 
-    if (BU_LIST_IS_EMPTY(&resp->re_solid_bitv)) {
+    if (!resp || BU_LIST_IS_EMPTY(&resp->re_solid_bitv)) {
        solidbits = bu_bitv_new((unsigned int)nbits);
     } else {
+       /* scan list for a reusable bitv */
        for (BU_LIST_FOR(solidbits, bu_bitv, &resp->re_solid_bitv)) {
            if (solidbits->nbits >= nbits) {
                BU_LIST_DEQUEUE(&solidbits->l);
@@ -853,6 +859,7 @@
            }
            counter++;
        }
+       /* no match, allocate a new one */
        if (solidbits == (struct bu_bitv *)&resp->re_solid_bitv) {
            solidbits = bu_bitv_new((unsigned int)nbits);
        }

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