Re: [Vala] probably silly question about vala objects



On Fri, Mar 18, 2011 at 10:23:00AM +0100, Luca Dionisi wrote:
How can I store in an ArrayList objects of any type, including simple types?

Suppose that at run-time I always know which type the next element really is.

Is that possible?

I am not an expert of C, but I think in C that would be something like:
  void *c = malloc(sizeof <<name_your_type>>);
  //
  // push c in a queue
  //...
  // pop c from the queue
  <<name_your_type>> *x = ( <<name_your_type>> *)c;
  // do something with x
  free(x);

But how could such a thing be written in Vala and use automatic memory
management?

Use GValue.

-- 
http://www.debian.org - The Universal Operating System

Attachment: signature.asc
Description: Digital signature



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