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

  • Re: is malloc thread-safe??
    ... C has this to say about reentrancy, ... static storage duration." ... and thread safety, So I would say that malloc is not thread safe. ... So malloc is NOT thread safe. ...
    (comp.lang.c)
  • Re: is malloc thread-safe??
    ... C has this to say about reentrancy, ... and thread safety, So I would say that malloc is not thread safe. ... So malloc is NOT thread safe. ...
    (comp.lang.c)
  • Re: Reentrant functions and memory allocation
    ... Why are people talking about malloc being or not being re-entrant? ... A function calling itself is recursion, not reentrancy. ... handlers, so the C Standard's statement that library functions aren't ... reentrant means that you can't call any library function from a signal ...
    (comp.lang.c)