Question: how brk and sbrk works?
Answer: brk() and sbrk() are different. brk is used to set the end of the data segment to the value you specify. ... Calling sbrk with 0 is valid; it is a way to get a pointer to the current data segment break address. malloc is not a system call, it's a C library function that manages memory using sbrk .