diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-12-12 04:18:21 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-12-12 04:18:21 +0000 |
commit | 869df3adbd02f8a151e54c3216155163979b99fe (patch) | |
tree | 2d24454c1e7cf8db87e56e03b1b69217366058c4 /source4 | |
parent | 16309de71d6c8de96e869aeaab0b879185991d87 (diff) | |
download | samba-869df3adbd02f8a151e54c3216155163979b99fe.tar.gz samba-869df3adbd02f8a151e54c3216155163979b99fe.tar.bz2 samba-869df3adbd02f8a151e54c3216155163979b99fe.zip |
handle the auto-allocation of [ref] output arrays in pidl. This
can simplify rpc servers a lot.
(This used to be commit 28fa62d63d020052a0d2f467f3f9cc6344aaf0ce)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/parser.pm | 12 | ||||
-rw-r--r-- | source4/rpc_server/rpc_echo.c | 8 |
2 files changed, 9 insertions, 11 deletions
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm index 88ba348486..d7f3814abd 100644 --- a/source4/build/pidl/parser.pm +++ b/source4/build/pidl/parser.pm @@ -318,14 +318,14 @@ sub ParseArrayPull($$$) if ((util::need_alloc($e) && !util::is_fixed_array($e)) || ($var_prefix eq "r->in." && util::has_property($e, "ref"))) { if (!util::is_inline_array($e) || $ndr_flags eq "NDR_SCALARS") { - pidl "\t\tNDR_ALLOC_N_SIZE(ndr, $var_prefix$e->{NAME}, MAX(1, $alloc_size), sizeof($var_prefix$e->{NAME}\[0]));\n"; + pidl "\t\tNDR_ALLOC_N(ndr, $var_prefix$e->{NAME}, MAX(1, $alloc_size));\n"; } } if (($var_prefix eq "r->out." && util::has_property($e, "ref"))) { if (!util::is_inline_array($e) || $ndr_flags eq "NDR_SCALARS") { pidl "\tif (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"; - pidl "\t\tNDR_ALLOC_N_SIZE(ndr, $var_prefix$e->{NAME}, MAX(1, $alloc_size), sizeof($var_prefix$e->{NAME}\[0]));\n"; + pidl "\t\tNDR_ALLOC_N(ndr, $var_prefix$e->{NAME}, MAX(1, $alloc_size));\n"; pidl "\t}\n"; } } @@ -1259,7 +1259,13 @@ sub ParseFunctionPull($) # we need to allocate any reference output variables, so that # a dcerpc backend can be sure they are non-null if (util::has_property($e, "out") && util::has_property($e, "ref")) { - pidl "\tNDR_ALLOC(ndr, r->out.$e->{NAME});\n"; + my $asize = util::array_size($e); + if (defined $asize) { + my $size = find_size_var($e, $asize, "r->out."); + pidl "\tNDR_ALLOC_N(ndr, r->out.$e->{NAME}, MAX(1, $size));\n"; + } else { + pidl "\tNDR_ALLOC(ndr, r->out.$e->{NAME});\n"; + } } } diff --git a/source4/rpc_server/rpc_echo.c b/source4/rpc_server/rpc_echo.c index 37b72f764b..d003f34ce4 100644 --- a/source4/rpc_server/rpc_echo.c +++ b/source4/rpc_server/rpc_echo.c @@ -31,10 +31,6 @@ static NTSTATUS echo_AddOne(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx, struc static NTSTATUS echo_EchoData(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx, struct echo_EchoData *r) { - r->out.out_data = talloc(mem_ctx, r->in.len); - if (!r->out.out_data) { - return NT_STATUS_NO_MEMORY; - } memcpy(r->out.out_data, r->in.in_data, r->in.len); return NT_STATUS_OK; @@ -48,10 +44,6 @@ static NTSTATUS echo_SinkData(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx, str static NTSTATUS echo_SourceData(struct dcesrv_state *dce, TALLOC_CTX *mem_ctx, struct echo_SourceData *r) { int i; - r->out.data = talloc(mem_ctx, r->in.len); - if (!r->out.data) { - return NT_STATUS_NO_MEMORY; - } for (i=0;i<r->in.len;i++) { r->out.data[i] = i; } |