FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
June 01, 1997

C++

(Page 2 of 9)

June 1997/Being Assertive in C/C++/Listing 1

Listing 1: Checking function parameters, index ranges, and order of function invocation

void AddCode( void *CodeLoc, unsigned CodeSize )
{
  assert( CodeLoc != NULL );
  ...
  int CodeOffset = Add( CodeLoc, CodeSize );
  ...
}


void MarkSelector( char* SelectorName )
{
  unsigned SelectorIndex = LookupSelector( SelectorName );
  assert( SelectorIndex < NumSelectors );
  SelectorArray[ SelectorIndex ].Mark = 1;
}


class CodeSection
{
  bool ContentComputed;
  long ContentSize;
  ...
  CodeSection( void )  { ContentComputed = false;  };
  void SetContentSize( long Size )
  {
    ContentSize = Size;
    ContentComputed = true;
  }
  long GetContentSize( void )
  {
    assert( ContentComputed );
    return ContentSize;
  }
}
//End of File
Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK