Re: [Vala] How to prevent gee.HashMap.set from copy the memory and only return the pointer?
- From: Jonas Kulla <nyocurio gmail com>
- To: Nadav Vinik <nadavvin gmail com>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] How to prevent gee.HashMap.set from copy the memory and only return the pointer?
- Date: Wed, 3 Jul 2013 02:25:05 +0200
2013/7/2 Nadav Vinik <nadavvin gmail com>
Hello
when I try to set an object to HashMap gee.HashMap.set try to copy the
memory of it with _vala_array_dup1 and it not allowed in my case.
public class pcapNode {
public uchar[] packet;
public PCap.packet_header* header;
}
var node = new pcapNode();
node.packet = packet;
node.header = &header;
this.map[i] = node;
_tmp34_ = pcap_node_new ();
node = _tmp34_;
_tmp35_ = node;
_tmp36_ = packet;
_tmp36__length1 = packet_length1;
_tmp37_ = (_tmp36_ != NULL) ? _vala_array_dup1 (_tmp36_, _tmp36__length1) :
((gpointer) _tmp36_);
I guess I should define packet as pointer to uchar[] but I didn't success
to do it.
Thanks
Nadav
--
הבלוג שלי:
http://nadavvin.com
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list
Hi,
it's not the HashMap trying to copy your array, but simply Vala syntax.
When you assign the array packet to node.packet, Vala treats this array
as a value type, meaning assignment equals copying. To stop it from doing
that,
try defining the 'packet' field in pcapNode as "unowned".
Jonas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]