diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-12-12 11:16:36 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-12-12 11:16:36 +0100 |
commit | 0f8d749144b60c62bbc9e0b934aecc2825d5d0d5 (patch) | |
tree | 9ac9d5c626cdf28bcdd34787d6b20e3bc9325c9e /pidl/lib/Parse/Pidl/Samba4.pm | |
parent | 306e9f14255cf04cf8f91e6a52ddc7faa160e55a (diff) | |
download | samba-0f8d749144b60c62bbc9e0b934aecc2825d5d0d5.tar.gz samba-0f8d749144b60c62bbc9e0b934aecc2825d5d0d5.tar.bz2 samba-0f8d749144b60c62bbc9e0b934aecc2825d5d0d5.zip |
Add convenience function for determining if an array should be allocated with talloc.
Diffstat (limited to 'pidl/lib/Parse/Pidl/Samba4.pm')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4.pm | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4.pm b/pidl/lib/Parse/Pidl/Samba4.pm index d42e01cdb0..5bdb91ee25 100644 --- a/pidl/lib/Parse/Pidl/Samba4.pm +++ b/pidl/lib/Parse/Pidl/Samba4.pm @@ -7,7 +7,7 @@ package Parse::Pidl::Samba4; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong); +@EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong ArrayDynamicallyAllocated); use Parse::Pidl::Util qw(has_property is_constant); use Parse::Pidl::NDR qw(GetNextLevel); @@ -36,6 +36,14 @@ sub choose_header($$) return "#include <$out>"; } +sub ArrayDynamicallyAllocated($$) +{ + my ($e, $l) = @_; + die("Not an array") unless ($l->{TYPE} eq "ARRAY"); + return 0 if ($l->{IS_FIXED} and not has_property($e, "charset")); + return 1; +} + sub NumStars($;$) { my ($e, $d) = @_; @@ -57,7 +65,7 @@ sub NumStars($;$) foreach my $l (@{$e->{LEVELS}}) { next unless ($l->{TYPE} eq "ARRAY"); - next if ($l->{IS_FIXED}) and not has_property($e, "charset"); + next unless (ArrayDynamicallyAllocated($e, $l)); $n++; } @@ -87,7 +95,7 @@ sub ArrayBrackets($) foreach my $l (@{$e->{LEVELS}}) { next unless ($l->{TYPE} eq "ARRAY"); - next unless ($l->{IS_FIXED}) and not has_property($e, "charset"); + next if ArrayDynamicallyAllocated($e, $l); $res .= "[$l->{SIZE_IS}]"; } |