summaryrefslogtreecommitdiff
path: root/tests/arrays/element-nullable-assignment.c-expected
blob: ffba74e24aecdc1229a3f22663090f821e48e588 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* arrays_element_nullable_assignment.c generated by valac, the Vala compiler
 * generated from arrays_element_nullable_assignment.vala, do not modify */

#include <glib.h>
#include <string.h>

#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

static void _vala_main (void);
static gint* _int_dup (gint* self);
static gboolean _int_equal (const gint * s1,
                     const gint * s2);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static gint*
_int_dup (gint* self)
{
	gint* dup;
	dup = g_new0 (gint, 1);
	memcpy (dup, self, sizeof (gint));
	return dup;
}

static gpointer
__int_dup0 (gpointer self)
{
	return self ? _int_dup (self) : NULL;
}

static gboolean
_int_equal (const gint * s1,
            const gint * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static void
_vala_main (void)
{
	gint** foo = NULL;
	gint _tmp0_;
	gint* _tmp1_;
	gint _tmp2_;
	gint* _tmp3_;
	gint _tmp4_;
	gint* _tmp5_;
	gint** _tmp6_;
	gint foo_length1;
	gint _foo_size_;
	gint* _tmp7_;
	gint _tmp8_;
	gint* _tmp9_;
	gint* _tmp10_;
	gint _tmp11_;
	gint* _tmp12_;
	gint* _tmp13_;
	gint _tmp14_;
	gint* _tmp15_;
	gint* _tmp16_;
	gint _tmp17_;
	gint* _tmp18_;
	gint _tmp19_;
	gint* _tmp20_;
	gint _tmp21_;
	_tmp0_ = 23;
	_tmp1_ = __int_dup0 (&_tmp0_);
	_tmp2_ = 42;
	_tmp3_ = __int_dup0 (&_tmp2_);
	_tmp4_ = 4711;
	_tmp5_ = __int_dup0 (&_tmp4_);
	_tmp6_ = g_new0 (gint*, 3);
	_tmp6_[0] = _tmp1_;
	_tmp6_[1] = _tmp3_;
	_tmp6_[2] = _tmp5_;
	foo = _tmp6_;
	foo_length1 = 3;
	_foo_size_ = foo_length1;
	_tmp7_ = foo[0];
	_tmp8_ = (*_tmp7_) + 1;
	_tmp9_ = __int_dup0 (&_tmp8_);
	_g_free0 (foo[0]);
	foo[0] = _tmp9_;
	_tmp10_ = foo[1];
	_tmp11_ = (*_tmp10_) * 3;
	_tmp12_ = __int_dup0 (&_tmp11_);
	_g_free0 (foo[1]);
	foo[1] = _tmp12_;
	_tmp13_ = foo[2];
	_tmp14_ = (*_tmp13_) - 2;
	_tmp15_ = __int_dup0 (&_tmp14_);
	_g_free0 (foo[2]);
	foo[2] = _tmp15_;
	_tmp16_ = foo[0];
	_tmp17_ = 24;
	_vala_assert (_int_equal (_tmp16_, &_tmp17_) == TRUE, "foo[0] == 24");
	_tmp18_ = foo[1];
	_tmp19_ = 126;
	_vala_assert (_int_equal (_tmp18_, &_tmp19_) == TRUE, "foo[1] == 126");
	_tmp20_ = foo[2];
	_tmp21_ = 4709;
	_vala_assert (_int_equal (_tmp20_, &_tmp21_) == TRUE, "foo[2] == 4709");
	foo = (_vala_array_free (foo, foo_length1, (GDestroyNotify) g_free), NULL);
}

int
main (int argc,
      char ** argv)
{
	_vala_main ();
	return 0;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}