From: Paul Rohr (paul@abisource.com)
Date: Thu May 30 2002 - 12:00:59 EDT
Sometimes it's very entertaining to browse through the source code.  For 
example, I ran across the following idiom this morning, and it made me 
chuckle:
    if(m_pHeaderSL)                                                         
    {                                                                       
        DELETEP(m_pHeaderSL);                                           
        m_pHeaderSL = NULL;    
    }
Why did I find this funny?  Well, take a look at the definition of the 
DELETEP macro in the following file:
  abi/src/af/util/xp/ut_types.h
It reads:
  #define DELETEP(p)		do { if (p) { delete(p); (p)=NULL; } } while (0)
In short, the whole reason we created those macros was to ensure that all 
delete, free, etc. calls did all of the nice null-sanity work you'd usually 
want.  Thus instead of typing the risky:
    delete m_pHeaderSL;
or the verbose-but-safer:
    if(m_pHeaderSL)                                                         
    {                                                                       
        delete m_pHeaderSL;                                           
        m_pHeaderSL = NULL;    
    }
you could just type:
    DELETEP(m_pHeaderSL);
and be done with it!
bottom line
-----------
We have convenience macros to wrap all of the following calls for pointers:
  free it
  delete it
  vector delete it
  delete and replace it
  ref-count it
  deref-count it 
If you're not sure how to use them, ask!
Paul
motto -- a little macro goes a long, long way
This archive was generated by hypermail 2.1.4 : Thu May 30 2002 - 12:04:37 EDT