Re: bug in g_mem_set_vtable() ?



On 30 Jul 2001, Sven Neumann wrote:

> Hi,
> 
> one of my collegues just pointed out a possible bug in glib/gmem.c.
> Shouldn't the boolean vtable_set be declared static here?
> 
> 
> Salut, Sven
> 
> Index: glib/gmem.c
> ===================================================================
> RCS file: /cvs/gnome/glib/glib/gmem.c,v
> retrieving revision 1.30
> diff -u -r1.30 gmem.c
> --- glib/gmem.c	2001/05/18 08:36:43	1.30
> +++ glib/gmem.c	2001/07/30 10:49:32
> @@ -224,11 +224,11 @@
>  void
>  g_mem_set_vtable (GMemVTable *vtable)
>  {
> -  gboolean vtable_set = FALSE;
> +  static gboolean vtable_set = FALSE;
>  

huh! yes, this should be a static variable in order to
supply apprpriate feedback if someone invokes this function
more than once.

>    if (!vtable_set)
>      {
> -      vtable_set |= TRUE;
> +      vtable_set = TRUE;
>        if (vtable->malloc && vtable->realloc && vtable->free)
>  	{
>  	  glib_mem_vtable.malloc = vtable->malloc;
> 

---
ciaoTJ





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