Revision: 69015
          http://sourceforge.net/p/brlcad/code/69015
Author:   brlcad
Date:     2016-10-11 05:59:38 +0000 (Tue, 11 Oct 2016)
Log Message:
-----------
badmagic fix highlight an error in here where the second internal magic number 
is not aligned because it comes after the array allocation and earlier magic.  
all this extra magic checking is overkill for a basic noise generator.

Modified Paths:
--------------
    brlcad/trunk/src/libbn/noise.c

Modified: brlcad/trunk/src/libbn/noise.c
===================================================================
--- brlcad/trunk/src/libbn/noise.c      2016-10-11 03:39:03 UTC (rev 69014)
+++ brlcad/trunk/src/libbn/noise.c      2016-10-11 05:59:38 UTC (rev 69015)
@@ -128,9 +128,7 @@
 struct str_ht {
     uint32_t magic;
     char hashTableValid;
-    uint32_t *hashTableMagic1;
     uint32_t *hashTable;
-    uint32_t *hashTableMagic2;
     uint32_t magic_end;
 };
 
@@ -145,12 +143,6 @@
 #define CK_HT() {                                                      \
        BU_CKMAG(&ht.magic, MAGIC_STRHT1, "struct str_ht ht 1");        \
        BU_CKMAG(&ht.magic_end, MAGIC_STRHT2, "struct str_ht ht 2");    \
-       BU_CKMAG(ht.hashTableMagic1, MAGIC_TAB1, "hashTable Magic 1");  \
-       BU_CKMAG(ht.hashTableMagic2, MAGIC_TAB2, "hashTable Magic 2");  \
-       if (ht.hashTable != &ht.hashTableMagic1[1])                     \
-           bu_bomb("ht.hashTable changed rel ht.hashTableMagic1");     \
-       if (ht.hashTableMagic2 != &ht.hashTable[TABLE_SIZE])            \
-           bu_bomb("ht.hashTable changed rel ht.hashTableMagic2");     \
     }
 
 
@@ -184,15 +176,8 @@
 
     BN_RANDSEED(rndtabi, (BN_RAND_TABSIZE-1));
 
-    /* alloc table size plus two magic numbers */
-    ht.hashTableMagic1 = (uint32_t *) bu_calloc(1, 2*sizeof(uint32_t) + 
TABLE_SIZE*sizeof(uint32_t), "noise hashTable");
+    ht.hashTable = (uint32_t *)bu_calloc(1, (TABLE_SIZE*sizeof(uint32_t)), 
"noise hashTable");
 
-    ht.hashTable = &ht.hashTableMagic1[1];
-    ht.hashTableMagic2 = &ht.hashTable[TABLE_SIZE];
-
-    *ht.hashTableMagic1 = (uint32_t)MAGIC_TAB1;
-    *ht.hashTableMagic2 = (uint32_t)MAGIC_TAB2;
-
     ht.magic_end = (uint32_t)MAGIC_STRHT2;
     ht.magic = (uint32_t)MAGIC_STRHT1;
 

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


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to