Re: how to test this piece of C code
- From: "subramanian100in@xxxxxxxxx, India" <subramanian100in@xxxxxxxxx>
- Date: 10 Mar 2007 02:53:37 -0800
On Mar 10, 12:59 pm, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
subramanian10...@xxxxxxxxx, India said:
<snip>
if (curSize > SIZE_MAX - blockSize)
Replace this code with:
if (curSize > MAX_BLOCK_LENGTH - blockSize)
and #define MAX_BLOCK_LENGTH in a header somewhere. For one thing, you
probably don't want it to be SIZE_MAX anyway (although, if you do, you
can define it as such in your header), and for another thing, it means
you can easily tweak it down to more easily tested values when need be
without having to hack at your source code each time.
You have suggested to have MAX_BLOCK_LENGTH as #defined. I have a
question on this. If I declare it as a const size_t and initialize
with SIZE_MAX, won't it help in getting seen by the debugger or is
there any specific reason for using #define here ?
.
- Follow-Ups:
- Re: how to test this piece of C code
- From: Richard Heathfield
- Re: how to test this piece of C code
- References:
- how to test this piece of C code
- From: subramanian100in@xxxxxxxxx, India
- Re: how to test this piece of C code
- From: Richard Heathfield
- Re: how to test this piece of C code
- From: subramanian100in@xxxxxxxxx, India
- Re: how to test this piece of C code
- From: Randy Howard
- Re: how to test this piece of C code
- From: subramanian100in@xxxxxxxxx, India
- Re: how to test this piece of C code
- From: Richard Heathfield
- Re: how to test this piece of C code
- From: Randy Howard
- Re: how to test this piece of C code
- From: Richard Heathfield
- how to test this piece of C code
- Prev by Date: Re: how to test this piece of C code
- Next by Date: Re: Converting Numbers to Words in English by recursion.
- Previous by thread: Re: how to test this piece of C code
- Next by thread: Re: how to test this piece of C code
- Index(es):
Relevant Pages
|