<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    On 10/30/2012 04:48 PM, Mark Lawrence wrote:
    <blockquote cite="mid:k6pov2$skk$1@ger.gmane.org" type="cite">On
      30/10/2012 15:47, Andrew Robinson wrote:
      <br>
      <blockquote type="cite">
        <br>
        I would refer you to a book written by Steve Maguire, Writing
        Solid
        <br>
        Code; Chapter 5; Candy machine interfaces.
        <br>
        <br>
      </blockquote>
      <br>
      The book that took a right hammering here
      <a class="moz-txt-link-freetext" href="http://accu.org/index.php?module=bookreviews&func=search&rid=467">http://accu.org/index.php?module=bookreviews&func=search&rid=467</a>
      ?
      <br>
      <br>
    </blockquote>
    <br>
    Yes, although Chapter 5 is the one where the realloc() issue is
    discussed.<br>
    If you have a library, see if you can check the book out -- rather
    than spend $$$ on it.<br>
    But, in good humor --  Consider the only criticism the poster
    mentioned about chapter 5's contents.<br>
    <blockquote>Occasionally, he presents a code fragment with a subtle
      bug, such as:
      <pre>p = realloc(p,n);</pre>
      <u>I have to admit that I didn't spot the bug</u>, but then I
      never use realloc,
      knowing it to have pitfalls. What is the bug? If realloc cannot
      allocate the
      memory, it returns NULL and the assignment means you lose your
      original
      pointer.
      <p>What are the pitfalls? Realloc may or may not copy the data to
        a new, larger,
        area of memory and return the address of that: many programmers
        forget this and
        end up with pointers into the old, deallocated, area. Even those
        programmers
        who remember will likely fall into the trap that Maguire shows.</p>
      <p><u>Back to 'clever' code though, he prefers</u>:</p>
    </blockquote>
    <br>
    His critique is a bit like the scene in Monty Python's the Life of
    Br..an...<br>
    Where the aliens come, and crash, and leave -- and is totally
    irrelevant to what the plot-line is in the movie.  What does this
    comment have to do with a critique???  McGuire didn't fail to notice
    the bug!<br>
    <br>
    But the critic doesn't even notice the main *pointS* the author was
    trying to make in that chapter.<br>
    There are, to be sure, recommendations that I don't agree with in
    the book;  He doesn't seem to do much Unit testing, postmortems,
    etc.  are all topics that I studied in a formal class on Software
    Engineering.  It was a wider perspective than McGuire brings to his
    book; <br>
    <br>
    But that doesn't mean McGuire has nothing valuable to say!<br>
    <br>
    A short Python Homage for readers of the linked Critique! :<br>
    <br>
    I've had to follow GPL project style rules where the rule for a
    weird situation would be:<br>
    while (*condition) /* nothing */ ;   // and yes, this will sometimes
    generate a warning...!!!!<br>
    <br>
    But, I have enough brains to take McGuire's *suggestion* to an
    improved Python conclusion.<br>
    <br>
    #define PASS(x) {(void)NULL;}<br>
    <br>
    while (*condition) PASS( Gas );  // There will be no warning!!!!<br>
    <br>
  </body>
</html>