Given a proto file:
package Foo.Common;
message NameValue {
optional string name = 1;
optional string value = 2;
}
Build the message and execute the following code:
#!/usr/bin/perl
use strict;
use warnings;
use Foo::Common::NameValue;
my $c;
foreach (1..3) {
foreach ('A'..'Z') {
my $m = Foo::Common::NameValue->new;
$c .= $_;
$m->set_name($c);
$m->set_value($c);
my $payload = $m->pack;
print "(" . length($c) . ") p: " . length($payload) . "\n";
}
}
I get the following (edited) result:
(1) p: 6
(2) p: 8
(3) p: 10
(4) p: 12
(5) p: 14
(6) p: 0 <-------------------
(7) p: 18
(8) p: 20
(9) p: 22
(10) p: 24
(11) p: 26
(12) p: 28
(13) p: 30
(14) p: 0 <-------------------
(15) p: 34
(16) p: 36
(17) p: 38
[...]
(26) p: 56
(27) p: 58
(28) p: 60
(29) p: 62
(30) p: 0 <-------------------
(31) p: 66
(32) p: 68
[...]
(60) p: 124
(61) p: 126
(62) p: 0 <-------------------
(63) p: 130
(64) p: 132
(65) p: 134
[...]
For whatever reason when the length of the pack would be a multiple of 8
the pack will return a zero length string...unless the length is exactly 8.
I have yet to look at the code, but it is interesting. :o)
--
seth /\ sethdaniel.org
Thanks Dave.
You know I never noticed the Issues tab before.
--
seth /\ sethdaniel.org