Can sbrk and malloc be used in the same program?
Siddhesh Poyarekar
siddhesh.poyarekar@gmail.com
Wed Aug 12 13:42:34 GMT 2020
On Wed, 12 Aug 2020 at 18:06, 孙世龙 sunshilong via Libc-help
<libc-help@sourceware.org> wrote:
> As per the representation(https://my.eng.utah.edu/~cs4400/malloc.pdf,
> page 3), which says:
> Do not use sbrk in a program that also uses malloc or anything that
> calls malloc (such as print).
>
> Is it right?
> If it's right, why?
malloc uses the heap area created by brk() to allocate memory, so
using brk() will interfere with malloc or any other library function
that uses malloc.
Siddhesh
--
http://siddhesh.in
More information about the Libc-help
mailing list