title: Why is the return value of the first sbrk different than subsequent calls?
body: <p>I am trying to understand how memory works in C, so am experimenting with the <code>sbrk</code> function now. I know that <code>sbrk(0)</code> should return the current program break, that is the end of the data segment.</p>
  
  <p>So I tried to call <code>sbrk(0)</code> multiple times and for some reason I get the first value different than the other values. For example, this program</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  
  int main()
  {
          void * currpb = sbrk(0);
          printf("The current program break is: %p.\n", currpb);
  
          void * newpb = sbrk(0);
          printf("The current program break is: %p.\n", newpb);
  
          void *new2pb = sbrk(0);
          printf("The current program break is: %p.\n", new2pb);
  
          void *new3pb = sbrk(0);
          printf("The current program break is: %p.\n", new3pb);
  }
  </code></pre>
  
  <p>Give me the following output:</p>
  
  <pre><code>The current program break is: 0x18b0000.
  The current program break is: 0x18d1000.
  The current program break is: 0x18d1000.
  The current program break is: 0x18d1000.
  </code></pre>
  
  <p>Am not sure why the 1st value is different than the other three values, any ideas?</p>