diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-09-24 11:58:02 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-09-24 11:58:02 +0200 |
commit | c4ce4acfb0d93ab34a4fd0d5199f3380ffea01c9 (patch) | |
tree | eb69abcebf41ffb77651f1a2d84bbd566b22091e | |
parent | f5d68c86765055ad8f1e2c47c5b18bd3bc58d716 (diff) | |
download | ffi-c4ce4acfb0d93ab34a4fd0d5199f3380ffea01c9.tar.gz |
Use the more efficient #put_char for writing the final \0 in #write_string
* And try to improve the clarity of the docs.
-rw-r--r-- | lib/ffi/pointer.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/ffi/pointer.rb b/lib/ffi/pointer.rb index 778f2b5..7d4d9f4 100644 --- a/lib/ffi/pointer.rb +++ b/lib/ffi/pointer.rb @@ -97,12 +97,12 @@ module FFI # @param [Numeric] len length of string to return # @return [self] # Write +str+ in pointer's contents. - # If +len+ is given, write the first +len+ bytes of +str+ - # and append a final \0 byte after the string. + # If +len+ is given, write the first +len+ bytes of +str+. + # In both cases a final \0 byte is written after the string. def write_string(str, len=nil) if len put_bytes(0, str, 0, len) - put_bytes(len, "\0") + put_char(len, 0) else put_string(0, str) end |