[Vala] g_new0



It seems like g_new0 is the hard-wired allocator for New() objects that aren't gobject managed.

How strong is the chance the a new CCode directive could be invented to override this?
e.g.
[CCode (new_function="talloc")]

or even

[CCode (new_expression="talloc(NULL, %s)")]


And, is this OK:
[CCode (cname = "struct ntvfs_module_context"

or should the "struct" be in another directive?
- however talloc allocator (which is a C macro) requires the type name, like this:

struct blah* = talloc(NULL, struct blah)

so if the struct had to be another directive, there would need to be a way to express it to the new allocator.

I realise that often a static method is used as a sly constructor, but it would be nice to do things nicely too.

And finally, is it possible to express C code directly in the .vapi files? That would be another way to express constructors and other things.

Sam



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