Re: [Vala] using a non-glib C library in vala



On Wed, Sep 16, 2009 at 15:46:34 -0400, Michael B. Trausch wrote:
On Wed, 2009-09-16 at 15:41 -0400, Michael B. Trausch wrote:
Did the meaning of [SimpleType] change somewhere?  I thought it meant
"pass by value". 

And pardon me, I'm not thinking very clearly.  That sounds wrong.

My thought was that a SimpleType could be allocated statically, and
passing it would do something like (in C, continuing the example from
earlier in the thread):

ip_address_t foo;
memset(&foo, 0, sizeof(ip_address_t));

I can see writing things like this being frowned upon, but my thought
was that a SimpleType was just that.  It seems instead that all
allocations are supposed to come from the heap via (one way or another)
malloc/free?  Or am I still misunderstanding something?

What you describe is the meaning of struct. Structs are always allocated
statically and always passed by value (unless ref modifier is used, of
course).

Passing by reference is indicated by declaring as 'class'. Classes are
supposed to support reference-counting, but if they don't, they can be
declared with [Compact] modifier.

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



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