X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/dab87ecc3bd6deafe058f7785093fd1c0b702eb5..e721e6b957228585cd9344b033628153564e8cdd:/scripts/protocol diff --git a/scripts/protocol b/scripts/protocol index 39b7dd5..f2a0c80 100755 --- a/scripts/protocol +++ b/scripts/protocol @@ -308,7 +308,8 @@ sub simple { my $name = $return->[1]; if($type eq 'string') { push(@c, - " *${name}p = v[$n];\n"); + " *${name}p = v[$n];\n", + " v[$n] = NULL;\n"); } elsif($type eq 'boolean') { push(@c, " if(boolean(\"$cmd\", v[$n], ${name}p))\n", @@ -321,7 +322,8 @@ sub simple { " *${name}p = atoll(v[$n]);\n"); } elsif($type eq 'user') { push(@c, - " c->user = v[$n];\n"); + " c->user = v[$n];\n", + " v[$n] = NULL;\n"); } elsif($type eq 'body') { push(@c, " if(readlist(c, ${name}p, n${name}p))\n", @@ -334,8 +336,11 @@ sub simple { die "$0: C API: unknown return type '$type' for '$name'\n"; } } + if($expected) { + push(@c, + " free_strings(nv, v);\n"); + } push(@c, " return 0;\n"); - # TODO xfree unconsumed split output } push(@c, "}\n\n");