Re: is malloc thread-safe??



On Jul 21, 6:44 pm, pete <pfil...@xxxxxxxxxxxxxx> wrote:
Chris Dollin wrote:
C doesn't have threads, so malloc is automatically thread-safe.

C has this to say about reentrancy,
"The functions in the standard library are not
guaranteed to be reentrant and may modify objects with
static storage duration."

A quick look at:

http://www.google.com/search?hl=en&ie=ISO-8859-1&safe=off&q=reentranc...

suggests that there is a connection between reentrancy
and thread safety, So I would say that malloc is not thread safe.

--
pete

Thanks all, for your answers.

So malloc is NOT thread safe. But can i know some conditions which i
should consider to make my own function thread safe.
i've developd my own memory allocator and now want to make it safe for
multithreaded programs.
can i get the key points to be considered.
Thanks.

.



Relevant Pages