Re: [Vala] Allocate memory for a struct pointer
- From: Guenther Niess <niess uni-potsdam de>
- To: vala-list gnome org
- Subject: Re: [Vala] Allocate memory for a struct pointer
- Date: Fri, 09 Dec 2011 00:14:15 +0100
Am 08.12.2011 20:00, schrieb Abderrahim Kitouni:
Hello,
في ث، 06-12-2011 عند 16:26 +0100 ، كتب Guenther Niess:
Hi,
I'm quite new and have a problem to initialize a struct. In the
tutorial and faq there are ways, but I think I have to manage the
memory manually in order to use libxml.
Here is an example of allocating the struct manually:
public struct MyStruct {
int i;
int j;
}
public void main () {
MyStruct* str = malloc (sizeof (MyStruct));
*str = MyStruct () {i = 1, j = 2};
print ("%d %d\n", str->i, str->j);
delete str;
}
Thanks a lot! That's what I was looking for, it works!
Guenther
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]