File: bug772426.vala

package info (click to toggle)
vala 0.56.18-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 57,468 kB
  • sloc: ansic: 581,293; sh: 5,334; makefile: 3,946; xml: 3,161; yacc: 1,219; lex: 374; javascript: 23
file content (18 lines) | stat: -rw-r--r-- 415 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int BUFFER_LENGTH = 1048576;

void main () {
	// Some reasonably sized memory block
	void* buffer_p = malloc (BUFFER_LENGTH);
	Memory.set (buffer_p, 0x55555555, BUFFER_LENGTH);
	unowned uint8[] buffer = (uint8[]) buffer_p;
	buffer.length = BUFFER_LENGTH;

	// Serialize
	Variant v = buffer;

	// Deserialize
	var result = (uint8[]) v;

	assert (Memory.cmp (buffer, result, BUFFER_LENGTH) == 0);
	free (buffer_p);
}