Re: how to test this piece of C code



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 ?

.



Relevant Pages

  • Re: how to test this piece of C code
    ... subramanian100in@xxxxxxxxx, India said: ... 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 ...
    (comp.programming)
  • Re: Running ping
    ... snip ... ... there is a header for just the ... The reason is that the interface is quite complicated. ... The ping.h header is included in the "netutils.h" header file, ...
    (comp.lang.c)
  • Re: if-modified-since question (protocol problem?)
    ... request, but in response you are interested only if your request ... To base the decision on whether there is something 'new to show' would require knowledge about something 'old' - a cached resource. ... No Last-Modified header is sent in the response, ...
    (comp.infosystems.www.authoring.html)
  • Re: using document.createElementNS or document.createElement
    ... 'looking at' the Accept header certainly isn't as simple as a substring match. ... It's in this latter area that content negotiation mechanisms seem to commit their worst offences. ... As there is no quality value associated with the media range at the end of the list, it means that everything is acceptable; only the explicitly listed types have a higher preference. ...
    (comp.lang.javascript)
  • Re: How to diagnose sendmail failure to some addresses?
    ... There will be a way for the sender to learn about the occurrence of and reason for a message failure if the mail handlers involved in the failure are configured in a traditional standards-compliant and robust manner and if the message is well-formed and sent using header and envelope addresses that provide a deliverable return path for error messages. ... header on the deliverdd mail. ...
    (comp.mail.sendmail)