Luca Bruno <[email protected]> wrote:
> On Tue, Oct 18, 2011 at 10:45 PM, Jan-Jaap van der Geer
> <[email protected]>wrote:
> > Pre Vala 0.13.2 I had code like this:
> > var foo = Foo();
> > Memory.copy(foo.Bar.Name, "foobar", 12);
> > This worked fine, as can be seen in the generated C:
> > f foo = {0};
> > memset (&foo, 0, sizeof (f));
> > memcpy (foo.bar.name, "foobar", (gsize) 12);
> > (aren't the {0} and the memset() doing the same thing?)
> Yes, ideally the memset could be avoided.
> Try using a pointer, like Foo* foo = &bar; and then call memcpy
> on foo->name.
Ah, great tip! Changing the code to:
Memory.copy(&foo.Bar.Name, "foobar", 12);
made it work:) Thanks!
Cheers,
Jan-Jaap
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list