title: Understanding C malloc and sbrk()
body: <p>I am trying to understand the difference between malloc and sbrk in C and how they relate to each other.  From what I understand malloc and sbrk are pretty much the same thing but I read that malloc uses sbrk in allocating memory.  This is really confusing can someone explain it to me?</p>
  
  <p>For example in this program does malloc call sbrk? if so does it simply call sbrk each time it gets called, so for this example 10 times?</p>
  
  <pre><code>int main(int argc, char **argv) {
          int i;
          void *start_pos, *finish_pos;
          void *res[10];
          start_pos = sbrk(0);
          for (i = 0; i &lt; 10; i++) {
                  res[i] = malloc(10);
          }
          finish_pos = sbrk(0);
          return 0;
  }
  </code></pre>
  
  <p>Thank you,</p>