[brlcad-commits] SF.net SVN: brlcad:[44982] brlcad/trunk/include/bu.h
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2011-06-14 19:55:35
|
Revision: 44982 http://brlcad.svn.sourceforge.net/brlcad/?rev=44982&view=rev Author: brlcad Date: 2011-06-14 19:55:27 +0000 (Tue, 14 Jun 2011) Log Message: ----------- add BU_LIST_INIT_ZERO, BU_BITV_INIT_ZERO, and BU_INIT_BITV macros for api consistency (lots more to go) Modified Paths: -------------- brlcad/trunk/include/bu.h Modified: brlcad/trunk/include/bu.h =================================================================== --- brlcad/trunk/include/bu.h 2011-06-14 19:55:09 UTC (rev 44981) +++ brlcad/trunk/include/bu.h 2011-06-14 19:55:27 UTC (rev 44982) @@ -753,6 +753,12 @@ }; #define BU_LIST_NULL ((struct bu_list *)0) +/** + * macro suitable for declaration statement initialization of a + * bu_list struct. does not allocate memory. + */ +#define BU_LIST_INIT_ZERO { BU_LIST_HEAD_MAGIC, BU_LIST_NULL, BU_LIST_NULL } + typedef struct bu_list bu_list_t; #define BU_LIST_CLOSE(hp) { \ @@ -885,6 +891,11 @@ /* Handle list initialization */ #define BU_LIST_UNINITIALIZED(hp) (UNLIKELY((hp)->forw == BU_LIST_NULL)) #define BU_LIST_IS_INITIALIZED(hp) (LIKELY((hp)->forw != BU_LIST_NULL)) + +/** + * initializes a bu_list struct without allocating any memory or list + * nodes. + */ #define BU_LIST_INIT(hp) { \ (hp)->forw = (hp)->back = (hp); \ (hp)->magic = BU_LIST_HEAD_MAGIC; /* used by circ. macros */ } @@ -1210,10 +1221,30 @@ bitv_t bits[2]; /**< @brief variable size array */ }; - +/** + * verifies the integrity of a bu_bitv struct + */ #define BU_CK_BITV(_vp) BU_CKMAG(_vp, BU_BITV_MAGIC, "bu_bitv") /** + * initializes a bu_bitv struct without allocating any memory + */ +#define BU_INIT_BITV(_bp) { \ + BU_INIT_LIST((_bp)->l); \ + BU_LIST_MAGIC_SET((_bp)->l, BU_BITV_MAGIC); \ + (_bp)->nbits = 0; \ + (_bp)->bits[0] = 0; \ + (_bp)->bits[1] = 0; \ + } + +/** + * macro suitable for declaration statement initialization of a bu_bitv + * struct. does not allocate memory. + */ +#define BU_BITV_INIT_ZERO { {BU_BITV_MAGIC, BU_LIST_NULL, BU_LIST_NULL}, 0, {0, 0} } + + +/** * b u _ b i t v _ s h i f t * * returns floor(log2(sizeof(bitv_t)*8.0)), i.e. the number of bits This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |