File: string-array-append.c-expected

package info (click to toggle)
vala 0.56.18-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 57,528 kB
  • sloc: ansic: 581,293; sh: 5,357; makefile: 3,980; xml: 3,161; yacc: 1,219; lex: 374; javascript: 23
file content (127 lines) | stat: -rw-r--r-- 3,751 bytes parent folder | download | duplicates (2)
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
/* basic_types_string_array_append.c generated by valac, the Vala compiler
 * generated from basic_types_string_array_append.vala, do not modify */

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

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_free0(var) (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 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 void
_vala_main (void)
{
	gchar** foo = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gint foo_length1;
	gint _foo_size_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	_tmp0_ = g_strdup ("foo");
	_tmp1_ = g_strdup ("bar");
	_tmp2_ = g_strdup ("foo bar");
	_tmp3_ = g_new0 (gchar*, 3 + 1);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	foo = _tmp3_;
	foo_length1 = 3;
	_foo_size_ = foo_length1;
	_tmp4_ = foo[0];
	_tmp5_ = g_strconcat (_tmp4_, "abc", NULL);
	_g_free0 (foo[0]);
	foo[0] = _tmp5_;
	_tmp6_ = foo[1];
	_tmp7_ = g_strdup_printf ("%i", 123);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strconcat (_tmp6_, _tmp8_, NULL);
	_g_free0 (foo[1]);
	foo[1] = _tmp9_;
	_g_free0 (_tmp8_);
	_tmp10_ = foo[2];
	_tmp11_ = g_strdup_printf ("%i", 123);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (" abc", _tmp12_, NULL);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_strconcat (_tmp10_, _tmp14_, NULL);
	_g_free0 (foo[2]);
	foo[2] = _tmp15_;
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_tmp16_ = foo[0];
	_vala_assert (g_strcmp0 (_tmp16_, "fooabc") == 0, "foo[0] == \"fooabc\"");
	_tmp17_ = foo[1];
	_vala_assert (g_strcmp0 (_tmp17_, "bar123") == 0, "foo[1] == \"bar123\"");
	_tmp18_ = foo[2];
	_vala_assert (g_strcmp0 (_tmp18_, "foo bar abc123") == 0, "foo[2] == \"foo bar abc123\"");
	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);
}