title: Is it better to allocate memory in the power of two?
body: <p>When we use <code>malloc()</code> to allocate memory, should we give the size which is in power of two? Or we just give the exact size that we need?
  <br/>Like</p>
  
  <pre><code>//char *ptr= malloc( 200 ); 
  char *ptr= malloc( 256 );//instead of 200 we use 256
  </code></pre>
  
  <p>If it is better to give size which is in the power of two, what is the reason for that? Why is it better?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The reason of my confusion is following quote from Joel's blog <a href="http://www.joelonsoftware.com/articles/fog0000000319.html" rel="noreferrer">Back to Basics</a></p>
  
  <blockquote>
    <p><strong>Smart programmers minimize the
    potential distruption of malloc  by
    always allocating blocks of memory
    that are powers of 2 in size.</strong> You
    know, 4 bytes, 8 bytes, 16 bytes,
    18446744073709551616 bytes, etc. For
    reasons that should be intuitive to
    anyone who plays with Lego, this
    minimizes the amount of weird
    fragmentation that goes on in the free
    chain. Although it may seem like this
    wastes space, it is also easy to see
    how it never wastes more than 50% of
    the space. So your program uses no
    more than twice as much memory as it
    needs to, which is not that big a
    deal.</p>
  </blockquote>
  
  <p>Sorry, I should have posted the above quote earlier. My apologies!<br/></p>
  
  <p>Most replies, so far, say that allocating memory in the power of two is a bad idea, then in which scenario its better to follow Joel's point about <code>malloc()</code>? Why did he say that? Is the above quoted suggestion obsolete now?</p>
  
  <p>Kindly explain it.<br/>
  Thanks</p>