Re: Dlls,memory allocation
- From: jacob navia <jacob@xxxxxxxxxxxxxxxx>
- Date: Tue, 21 Nov 2006 07:39:00 +0100
Sundar wrote:
Hi,This is a good idea not only for dlls but for
i am trying to make an application that will require registering of
quite a few dlls and execute. Now one of the first bottlenecks that my
mentor refused is allocation of memory or the usage of mallocs in the
dlls. He tells me that for an application to run perfectly , there must
be no dynamic memory in the libraries.. I am not quite impressed..
Can anyone clear out this mess please?
normal libraries too.
If you allocate memory in the library, it could be that the user thinks
he can free it. That would be catastrophic if your library was compiled
with another compiler and has another runtime free/malloc system than
what the user of the library is using.
You can only allocate memory if you also provide a means for freeing
the memory in your library. In that case, the allocation /freeing will
work. Whether it is a good practice it is another thing.
A cleaner interface is when the user makes all allocations/freeing
and your library uses the memory it is provided to work with: you
receive pointers to buffers, etc.
.
- Follow-Ups:
- Re: Dlls,memory allocation
- From: Jens Thoms Toerring
- Re: Dlls,memory allocation
- Prev by Date: Re: Dlls,memory allocation
- Next by Date: Re: doubt structure assignment
- Previous by thread: Re: Dlls,memory allocation
- Next by thread: Re: Dlls,memory allocation
- Index(es):
Relevant Pages
|