gendispatch: use g_new0 instead of VIR_ALLOC

Take the easy way out and use typeof, because my life
is too short to spend it reading gendispatch.pl.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2020-09-30 15:40:06 +02:00
parent d59b6070d7
commit 99c709765a

View File

@ -797,8 +797,7 @@ elsif ($mode eq "server") {
push(@free_list, " VIR_FREE($1);");
push(@free_list_on_error, "VIR_FREE($1_p);");
push(@prepare_ret_list,
"if (VIR_ALLOC($1_p) < 0)\n" .
" goto cleanup;\n" .
"$1_p = g_new0(char *, 1);\n" .
"\n" .
" *$1_p = g_strdup($1);\n");
@ -1126,9 +1125,9 @@ elsif ($mode eq "server") {
if ($single_ret_as_list) {
print " /* Allocate return buffer. */\n";
print " if (VIR_ALLOC_N(ret->$single_ret_list_name.${single_ret_list_name}_val," .
" args->$single_ret_list_max_var) < 0)\n";
print " goto cleanup;\n";
print " ret->$single_ret_list_name.${single_ret_list_name}_val =\n";
print " g_new0(typeof(*ret->$single_ret_list_name.${single_ret_list_name}_val), " .
"args->$single_ret_list_max_var);\n";
print "\n";
}
@ -1188,8 +1187,8 @@ elsif ($mode eq "server") {
print " }\n";
print "\n";
print " if (result && nresults) {\n";
print " if (VIR_ALLOC_N(ret->$single_ret_list_name.${single_ret_list_name}_val, nresults) < 0)\n";
print " goto cleanup;\n";
print " ret->$single_ret_list_name.${single_ret_list_name}_val =\n";
print " g_new0(typeof(*ret->$single_ret_list_name.${single_ret_list_name}_val), nresults);\n";
print "\n";
print " ret->$single_ret_list_name.${single_ret_list_name}_len = nresults;\n";
if ($modern_ret_is_nested) {
@ -1950,8 +1949,7 @@ elsif ($mode eq "client") {
$priv_src =~ s/->conn//;
}
print " if (result) {\n";
print " if (VIR_ALLOC_N(tmp_results, ret.$single_ret_list_name.${single_ret_list_name}_len + 1) < 0)\n";
print " goto cleanup;\n";
print " tmp_results = g_new0(typeof(*tmp_results), ret.$single_ret_list_name.${single_ret_list_name}_len + 1);\n";
print "\n";
print " for (i = 0; i < ret.$single_ret_list_name.${single_ret_list_name}_len; i++) {\n";
print " tmp_results[i] = get_nonnull_$modern_ret_struct_name($priv_src, ret.$single_ret_list_name.${single_ret_list_name}_val[i]);\n";