Martín Vales <mar...@opengeomap.org> writes:

> hi:
>
> I working with visual c++ in Windows and i find glib very useful for
> many C task, but i am worry about the g_malloc overhead.
>
> We really need a new malloc??
>
> gpointer
> g_malloc (gsize n_bytes)
> {
>  if (G_UNLIKELY (!g_mem_initialized))
>    g_mem_init_nomessage();
>  if (G_LIKELY (n_bytes))
>    {
>      gpointer mem;
>
>      mem = glib_mem_vtable.malloc (n_bytes);
>      if (mem)
>    return mem;
>
>      g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes",
>               G_STRLOC, n_bytes);
>    }
>
>  return NULL;
> }
>
>
>
>
>
> What are the advantages of use a glib_mem_vtable ???. I think we have
> the same malloc function in all operating systems?.
> static GMemVTable glib_mem_vtable = {
>  standard_malloc,
>  standard_realloc,
>  standard_free,
>  standard_calloc,
>  standard_try_malloc,
>  standard_try_realloc,
> };
>

g_malloc will abort program when no additional memory is avaible (as
usually programers do not care about handling it as it would require
usually... allocating memory). 

From g_try_malloc:
"Attempts to allocate n_bytes, and returns NULL on failure. Contrast
with g_malloc(), which aborts the program on failure. " 

>
> Other overhead i see is the open dir/file funtions, where in windows
> we need do the utf8 to utf16 everytime in windows. If JAVA,.NET and Qt
> use utf16 by default why in gnome world we use utf8 by default?.
>

I guess that:
1. Because utf-8 is currently the main coding for unicode I guess (see
xml & co.)
2. Because the most strings in latin alphabet will be nearly 2x smaller
then in utf-16 (on average in my mother language AFAIR utf-8 is bigger
by a few % then iso-8859-2 - utf-16 would by 100% bigger)
3. I guess that utf-8 is a standard on main Gnome platform -
GNU/Linux. While I met in many places generating xx_XX.UTF-8 locales
I've never encountered utf-16.
4. utf-16 is not fixed size so this is not an advantage over utf-8
(utf-32 is).

Regards
-- 
I've probably left my head... somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to