Re: Glib: a Win32 discussion

On Sun, 2011-04-10 at 12:46 +0200, Hans Breuer wrote:

> > The first thing that should change is making g_malloc and
> > friends use the HeapAlloc function, and ensure that
> > g_mem_is_system_malloc() always returns false. This is really easy to do
> > and shouldn't upset the apple-cart too much.
> >
> This would break a lot more code than currently is broken. But you can 
> already do this by using g_mem_set_vtable() in your application.
> > Memory allocation is the easy bit. HeapAlloc maps nicely onto malloc.
> Not really if there are libraries with CRT dependencies involved.

Hmm, I'm confused here, in two ways.

First of all, what makes switching g_malloc to HeapAlloc useful? Since
g_malloc must always be paired with g_free which is from the same dll,
there can never be any multiple-crt issues?

I can see how making g_mem_is_system_malloc return FALSE makes sense
though, as the definition of "system" here is problematic (multiple such
versions exists). I'm pretty sure g_mem_is_system_malloc isn't that
heavily used anyway (found 3 uses outside glib in my full gnome
checkout), so this would probably not be a problem.

Secondly, Hans, how can such a change break apps? This is a valid setup,
so any code that is broken by this is already "broken" since it matches
g_malloc/free and malloc/free without checking g_mem_is_system_malloc.
Any such problems should be fixed and freed.

 Alexander Larsson                                            Red Hat, Inc 
       alexl redhat com            alexander larsson gmail com 
He's an oversexed misogynist matador from the 'hood. She's a strong-willed 
cat-loving journalist who don't take no shit from nobody. They fight crime! 

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