Branch: Tag:

2008-01-30

2008-01-30 13:29:55 by Per Hedbor <ph@opera.com>

Tried to clean up the memory handling. At least valgrind is reasonably silent now. :-) This should actually be done for GTK1 too, but it's not as essential.

Rev: src/post_modules/GTK2/build_pgtk.pike:1.14
Rev: src/post_modules/GTK2/pgtk.h:1.18
Rev: src/post_modules/GTK2/source/gdkbitmap.pre:1.7
Rev: src/post_modules/GTK2/source/gdkcolor.pre:1.6
Rev: src/post_modules/GTK2/source/gdkcolormap.pre:1.5
Rev: src/post_modules/GTK2/source/gdkdisplay.pre:1.11
Rev: src/post_modules/GTK2/source/gdkdragcontext.pre:1.5
Rev: src/post_modules/GTK2/source/gdkevent.pre:1.11
Rev: src/post_modules/GTK2/source/gdkgc.pre:1.15
Rev: src/post_modules/GTK2/source/gdkimage.pre:1.7
Rev: src/post_modules/GTK2/source/gdkpixbuf.pre:1.21
Rev: src/post_modules/GTK2/source/gdkpixbufanimation.pre:1.6
Rev: src/post_modules/GTK2/source/gdkpixmap.pre:1.6
Rev: src/post_modules/GTK2/source/gdkrectangle.pre:1.9
Rev: src/post_modules/GTK2/source/gdkregion.pre:1.5
Rev: src/post_modules/GTK2/source/gdkscreen.pre:1.8
Rev: src/post_modules/GTK2/source/gdkvisual.pre:1.3
Rev: src/post_modules/GTK2/source/gdkwindow.pre:1.7
Rev: src/post_modules/GTK2/source/gtkcelllayout.pre:1.5
Rev: src/post_modules/GTK2/source/gtkcellview.pre:1.11
Rev: src/post_modules/GTK2/source/gtkclipboard.pre:1.6
Rev: src/post_modules/GTK2/source/gtkcolorbutton.pre:1.10
Rev: src/post_modules/GTK2/source/gtkiconinfo.pre:1.6
Rev: src/post_modules/GTK2/source/gtkicontheme.pre:1.8
Rev: src/post_modules/GTK2/source/gtkpapersize.pre:1.4
Rev: src/post_modules/GTK2/source/gtkrecentinfo.pre:1.5
Rev: src/post_modules/GTK2/source/gtktextattributes.pre:1.8
Rev: src/post_modules/GTK2/source/gtktextiter.pre:1.12
Rev: src/post_modules/GTK2/source/gtktextmark.pre:1.7
Rev: src/post_modules/GTK2/source/gtktextview.pre:1.9
Rev: src/post_modules/GTK2/source/gtktreeiter.pre:1.6
Rev: src/post_modules/GTK2/source/gtktreepath.pre:1.9
Rev: src/post_modules/GTK2/source/gtktreerowreference.pre:1.7
Rev: src/post_modules/GTK2/source/gtktreeview.pre:1.11
Rev: src/post_modules/GTK2/source/pangocontext.pre:1.7
Rev: src/post_modules/GTK2/source/pangofontdescription.pre:1.8
Rev: src/post_modules/GTK2/source/pangolayoutiter.pre:1.7
Rev: src/post_modules/GTK2/source/pangotabarray.pre:1.7
Rev: src/post_modules/GTK2/source/support.c:1.20

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: support.c,v 1.19 2008/01/29 12:17:26 per Exp $ + || $Id: support.c,v 1.20 2008/01/30 13:29:55 per Exp $   */      #include <version.h>
277:   }       - void push_pgdk2object(void *obj, struct program *def) { + void push_pgdk2object(void *obj, struct program *def, int owned) {    struct object *o;    if (!obj) {    push_int(0);
286:    o=low_clone(def);    call_c_initializers(o);    ((struct object_wrapper *)o->storage)->obj=obj; -  -  /* TODO: Check all usage of this function to see that it does not -  * assume 2 refs on the object instead of 1. -  */ +  ((struct object_wrapper *)o->storage)->owned = owned;    push_object(o);    return;   }
430:      void push_atom(GdkAtom a) {    /* this should really be inserted in the GDK.Atom mapping. */ -  push_pgdk2object((void *)a,pgdk2__atom_program); +  push_pgdk2object((void *)a,pgdk2__atom_program,0);   }      void push_Xpseudo32bitstring(void *f, int nelems) {
465:    return;    }    *f=*e; -  push_gdkobject(f,event); +  push_gdkobject(f,event,1);    } else    push_int(0);   }
495:   */      static int pgtk2_push_gdk_drag_context_param(const GValue *a) { -  push_gdkobject(g_value_get_pointer(a),drag_context); +  push_gdkobject(g_value_get_pointer(a),drag_context,0);    return PUSHED_VALUE;   }   
577:    if (g_type_is_a(G_VALUE_TYPE(a),G_TYPE_BOXED)) {    gp=g_value_get_boxed(a);    if (G_VALUE_HOLDS(a,g_type_from_name("GdkColor"))) { -  push_gdkobject(gp,color); +  push_gdkobject(gp,color,0);    } else if (G_VALUE_HOLDS(a,g_type_from_name("GtkTreePath"))) { -  pgtk2_push_gobjectclass(gp,pgtk2_tree_path_program); +  push_pgdk2object(gp,pgtk2_tree_path_program,0);    } else if (G_VALUE_HOLDS(a,g_type_from_name("GdkRectangle"))) { -  push_gdkobject(gp,rectangle); +  push_gdkobject(gp,rectangle,0);    } else if (G_VALUE_HOLDS(a,g_type_from_name("GdkRegion"))) { -  push_gdkobject(gp,region); +  push_gdkobject(gp,region,0);    }    } else {    obj=g_value_get_object(a);
1131:    if (gc==NULL)    Pike_error("Out of memory allocating %d bytes\n",sizeof(GdkColor));    g_object_get(g,prop,gc,NULL); -  push_gdkobject(gc,color); +  push_gdkobject(gc,color,1);    } else {    Pike_error("Unable to handle type %s.\n",g_type_name(gps->value_type));    }
1258:    int res;   /* push_gobjectclass(model,pgtk2_tree_model_program); */    push_gobject(model); -  push_gobjectclass(a,pgtk2_tree_iter_program); -  push_gobjectclass(b,pgtk2_tree_iter_program); +  push_pgdk2object(a,pgtk2_tree_iter_program,0); +  push_pgdk2object(b,pgtk2_tree_iter_program,0);    push_svalue(&d->args);    apply_svalue(&d->cb,4);    res=Pike_sp[-1].u.integer;