mirror of
https://github.com/samba-team/samba.git
synced 2025-08-29 13:49:30 +03:00
handle the auto-allocation of [ref] output arrays in pidl. This
can simplify rpc servers a lot.
(This used to be commit 28fa62d63d
)
This commit is contained in:
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user