June 01, 1997
C++
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