diff options
author | Richard Jones <rjones@redhat.com> | 2010-03-25 19:44:22 +0000 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-03-25 19:44:22 +0000 |
commit | 57c143da4d9b9e75e6da83ef3b8e8c0979c6f0f6 (patch) | |
tree | f4459d61555fa98804a69391202f118dc71fc7a3 /src | |
parent | 3e9d96d246f75bd7d2aa592b84bd6446687cad85 (diff) | |
download | libguestfs-57c143da4d9b9e75e6da83ef3b8e8c0979c6f0f6.tar.gz libguestfs-57c143da4d9b9e75e6da83ef3b8e8c0979c6f0f6.tar.xz libguestfs-57c143da4d9b9e75e6da83ef3b8e8c0979c6f0f6.zip |
perl: use newSVpvn for variable length strings.
Previously we used newSVpv (str, len), but if len == 0 then
this means Perl tries to calculate the string length using
strlen(3). This is not desirable when we know the length, in
which case we should use newSVpvn instead.
Diffstat (limited to 'src')
-rwxr-xr-x | src/generator.ml | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/generator.ml b/src/generator.ml index 5f5b4370..b04bbe03 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -8327,7 +8327,7 @@ DESTROY (g) do_cleanups (); pr " if (%s == NULL)\n" n; pr " croak (\"%%s\", guestfs_last_error (g));\n"; - pr " RETVAL = newSVpv (%s, size);\n" n; + pr " RETVAL = newSVpvn (%s, size);\n" n; pr " free (%s);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8360,7 +8360,7 @@ and generate_perl_struct_list_code typ cols name style n do_cleanups = pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s, 32), 0);\n" name (String.length name) n name | name, FBuffer -> - pr " (void) hv_store (hv, \"%s\", %d, newSVpv (%s->val[i].%s, %s->val[i].%s_len), 0);\n" + pr " (void) hv_store (hv, \"%s\", %d, newSVpvn (%s->val[i].%s, %s->val[i].%s_len), 0);\n" name (String.length name) n name n name | name, (FBytes|FUInt64) -> pr " (void) hv_store (hv, \"%s\", %d, my_newSVull (%s->val[i].%s), 0);\n" @@ -8402,7 +8402,7 @@ and generate_perl_struct_code typ cols name style n do_cleanups = pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 0)));\n" n name | name, FBuffer -> - pr " PUSHs (sv_2mortal (newSVpv (%s->%s, %s->%s_len)));\n" + pr " PUSHs (sv_2mortal (newSVpvn (%s->%s, %s->%s_len)));\n" n name n name | name, FUUID -> pr " PUSHs (sv_2mortal (newSVpv (%s->%s, 32)));\n" |