GNOME Bugzilla – Bug 728274
Using sizeof() with classes is borked
Last modified: 2018-05-22 15:08:26 UTC
From version 0.23.2 the GDK event structures are compact classes. To create/setup/destroy them manually this kind of code should work: Gdk.EventKey* eventkey = (Gdk.EventKey*) GLib.malloc (sizeof (Gdk.EventKey)); (*eventkey).keyval = (uint)Gdk.Key.k; GLib.free(eventkey); but it results error: Pointer indirection not supported for this expression (*eventkey).keyval = (uint)Gdk.Key.k; ^^^^^^^^^ This version: Gdk.EventKey* eventkey = (Gdk.EventKey*) GLib.malloc (sizeof (Gdk.EventKey)); eventkey->keyval = (uint)Gdk.Key.k; GLib.free(eventkey); compiles but results in: free(): invalid next size (fast): 0x0000000001240010 *** without the line "eventkey->keyval = (uint)Gdk.Key.k" compiles and runs without error.
Just found Gdk.Event has a constructor: var ev = new Gdk.Event (Gdk.EventType.KEY_PRESS); for example.
class Foo { } sizeof(Foo) doesn't work for classes while a pointer is passed and therefore results in sizeof(Foo*)
Created attachment 369467 [details] [review] codegen: Avoid passing a pointer to sizeof() if is not intended
Review of attachment 369467 [details] [review]: Still breaks a bunch of stuff.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/442.