Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: Is malloc()...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 1085 of 1134
Post > Topic >>

Re: Is malloc() function provided in <stdlib.h> thread-safe?

by Thomas Richter <thor@[EMAIL PROTECTED] > May 5, 2008 at 04:00 PM

climber.cui@[EMAIL PROTECTED]
 wrote:
> Hi all,
>   Does anyone have experience on the thread-safty issue with malloc()?

On any *reasonable* implementation sup****ting threads, malloc
is thread safe, all provided you link with the proper library.

> Some people said this function provided in stdlib.h is not thread-
> safe, but someone said it is thread safe.  Is it possible this
> function evolves from thread-unsafe to thread-safe in recent years?

Hardly. Having threads but a non-thread-safe version of malloc() isn't
going to be helpful.

> How could i find out?

Study your compiler manual. ANSI-C doesn't say anything about threads,
it's a POSIX extension to C.

>   I am using the C library coming with GNU linux distribution.

Compile and link with -pthreads and malloc() will be thread-safe, on x86 
and AMD64.

So long,
	Thomas
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 8 Posts in Topic:
Is malloc() function provided in thread-safe?
climber.cui@[EMAIL PROTEC  2008-04-21 13:20:27 
Re: Is malloc() function provided in thread-safe?
Thomas Richter <thor@[  2008-05-05 16:00:54 
Re: Is malloc() function provided in thread-safe?
Kenneth Brody <kenbrod  2008-05-05 16:00:57 
Re: Is malloc() function provided in thread-safe?
gordonb.cp95r@[EMAIL PROT  2008-05-05 16:01:01 
Re: Is malloc() function provided in thread-safe?
Barry Schwarz <schwarz  2008-05-05 16:01:08 
Re: Is malloc() function provided in thread-safe?
=?utf-8?Q?Dag-Erling_Sm=C  2008-05-05 16:01:20 
Re: Is malloc() function provided in thread-safe?
Kalle Olavi Niemitalo <  2008-05-05 16:01:22 
Re: Is malloc() function provided in thread-safe?
Andrei Voropaev <avoro  2008-05-05 16:01:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:37:34 CDT 2008.