comp.lang.c
[Top] [All Lists]

Re: Reentrant functions and memory allocation

Subject: Re: Reentrant functions and memory allocation
From: santosh
Date: Sun, 30 Mar 2008 19:26:55 +0530
Newsgroups: comp.lang.c

fmassei@xxxxxxxxx wrote:

> Dear all,
> I'm trying to put some old code in a portable, cross-platform library
> and I'm facing a big problem: is there a standard, platform-
> independent way to write a reentrant function that allocate dynamic
> memory? In other words: is it safe to use malloc() or free() in a
> thread-safe function?
> Thank you,
> Francesco

I think most malloc implementations are reentrant. All you need to do is
to ensure that your data objects are also thread safe, which means
using as few static objects as possible.


<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy