06a9e368b9b085df0c78c5391decbd1ced9da8b6
tdreszer
  Thu Jul 28 16:23:17 2011 -0700
Cleaned up the tdbExtras a little.  Jim recommended always allocating.  Currently leaving in an assert, but will remove it on next check-in
diff --git src/hg/inc/trackDb.h src/hg/inc/trackDb.h
index efedd93..ae0c260 100644
--- src/hg/inc/trackDb.h
+++ src/hg/inc/trackDb.h
@@ -512,40 +512,40 @@
 struct tdbExtras
 // Struct for misc. data collected/calculated during CGI track setup that are cached for later use.
 // These extras are primarily used in hgTracks & hgTrackUi but can be used and expanded as needed.
 // CGI developers are encouraged to add to this structure for their own needs.
     {
     int fourState; // hgTrackUi subtracks use 4 state checkboxes (checked/un by enabled/dis)
     boolean reshapedComposite; // hgTracks should not "reshape" composites more than once.
     struct mdbObj *mdb;        // several CGIs need repeated access to a tracks metadata
     struct _membersForAll *membersForAll; // hgTrackUi composites collect all view/dimension info
     struct _membership *membership;       // hgTrackUi subtracks have individual membership info
 
     // Developer: please add your useful data that is costly to calculate/retrieve more than once
     };
 
 #define TDB_EXTRAS_EMPTY_STATE 666
+struct tdbExtras *tdbExtrasNew(void);
+// Return a new empty tdbExtras
+
+void tdbExtrasFree(struct tdbExtras **pTdbExtras);
+// Frees the tdbExtras structure
+
 INLINE struct tdbExtras *tdbExtrasGet(struct trackDb *tdb)
 // Returns tdbExtras struct, initializing if needed.
 {
-if(tdb->tdbExtras == NULL)
-    {
-    tdb->tdbExtras = AllocVar(tdb->tdbExtras);
-    // Initialize any values that need an "empty" state
-    tdb->tdbExtras->fourState = TDB_EXTRAS_EMPTY_STATE; // I guess it is 5 state!
-    // pointers are NULL and booleans are FALSE by default
-    }
+assert(tdb->tdbExtras != NULL);
 return tdb->tdbExtras;
 }
 
 INLINE int tdbExtrasFourState(struct trackDb *tdb)
 // Returns subtrack four state if known, else TDB_EXTRAS_EMPTY_STATE
 {
 return tdbExtrasGet(tdb)->fourState;
 }
 
 INLINE void tdbExtrasFourStateSet(struct trackDb *tdb,int fourState)
 // Sets subtrack four state
 {
 tdbExtrasGet(tdb)->fourState = fourState;
 }