Re: [gtk-list] Mixing malloc/g_malloc (Was: g_malloc() aborts when enough memory is not found)



Hi, Trog

Thanks a lot for your answer.

Trog wrote:
> 
> I think you're a bit confused by what Owen meant about mixing calls
> to g_malloc()/g_free() and malloc()/free().
> 
> What you *can't* do is allocate memory with g_malloc() and free that
> allocated memory with free(); neither can you allocate memory with
> malloc() and then free that memory with g_free().
> 
> You can do basically anything else. Mixing applications that use
> malloc/free and g_malloc/g_free on the same system is fine.

That's exactly what I thought.
I did ask this question because all my applications do work
on FreeBSD, i.e. the malloc()-only programs as well as the ones with
the GTK interface (which uses g_malloc() etc.).
However, on Sun Solaris - with the same GTK/Glib version (1.2.3) - the
programs using just malloc() do work fine, but using a mix of
malloc()/g_malloc() and free()/g_free() crash at the second malloc().

> You can also use malloc()/free() inside a GTK application as long as
> you do so *consistently*
I think I'll do it, because I don't call g_malloc()/g_free() explicitly
in my programs. Just GTK will do it.
But, I'll check it again, just to be 150% sure.

Thanks again,

Norbert.

-- 
Norbert Bladt		 Payphone Management System Software Development
ascom Autelca AG
Worbstrasse 201		 CH-3073 Guemligen, Switzerland
abladtn@autelca.ascom.ch VOICE: +41 31 999 6552, FAX: +41 31 999 6575



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]