Re: g_malloc overhead
- From: Maciej Piechotka <uzytkownik2 gmail com>
- To: gtk-devel-list gnome org
- Cc: gtk-app-devel-list gnome org
- Subject: Re: g_malloc overhead
- Date: Fri, 23 Jan 2009 02:36:13 +0100
Martín Vales <martin 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).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]