summaryrefslogtreecommitdiffstats
path: root/pidl/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-09-26 20:38:12 +0200
committerStefan Metzmacher <metze@samba.org>2014-01-07 08:37:38 +0100
commit2ba9453e9ff5d911a146e786ff8878ef67717366 (patch)
tree054c426df8b9eb6390ebc79652384b9e4bfa9209 /pidl/lib
parentf50b561336c7b6c08300e6e477859d1f9fab62c2 (diff)
downloadsamba-2ba9453e9ff5d911a146e786ff8878ef67717366.tar.gz
samba-2ba9453e9ff5d911a146e786ff8878ef67717366.tar.xz
samba-2ba9453e9ff5d911a146e786ff8878ef67717366.zip
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>
Diffstat (limited to 'pidl/lib')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index f02b8b20251..b4954ca6241 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -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("}");