1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

pidl:NDR/Client: avoid useless memcpy()

If the src and dest pointer of memcpy would be the same
we should avoid it in order to avoid valgrind warnings.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Stefan Metzmacher 2013-09-26 20:38:12 +02:00
parent f50b561336
commit 2ba9453e9f

View File

@ -400,11 +400,16 @@ sub ParseOutputArgument($$$$$$)
$self->pidl("$copy_len_var = $out_length_is;");
}
my $dest_ptr = "$o$e->{NAME}";
my $elem_size = "sizeof(*$dest_ptr)";
$self->pidl("if ($dest_ptr != $out_var) {");
$self->indent;
if (has_property($e, "charset")) {
$self->pidl("memcpy(discard_const_p(uint8_t *, $o$e->{NAME}), $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
} else {
$self->pidl("memcpy($o$e->{NAME}, $out_var, $copy_len_var * sizeof(*$o$e->{NAME}));");
$dest_ptr = "discard_const_p(uint8_t *, $dest_ptr)";
}
$self->pidl("memcpy($dest_ptr, $out_var, $copy_len_var * $elem_size);");
$self->deindent;
$self->pidl("}");
$self->deindent;
$self->pidl("}");