diff options
author | Armin Rigo <arigo@tunes.org> | 2021-12-24 10:13:24 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2021-12-24 10:13:24 +0100 |
commit | a333c4996bb4436d34a0dd04d46632402c66a866 (patch) | |
tree | 444732116573e93ce1fd58d8ac2ee36d1efb6474 /doc/source | |
parent | fbc4f4383312ac4110422d6e2eeed7200ab4e271 (diff) | |
download | cffi-a333c4996bb4436d34a0dd04d46632402c66a866.tar.gz |
tweak wording
Diffstat (limited to 'doc/source')
-rw-r--r-- | doc/source/using.rst | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/doc/source/using.rst b/doc/source/using.rst index 6432f4a..ccaa4db 100644 --- a/doc/source/using.rst +++ b/doc/source/using.rst @@ -385,12 +385,15 @@ argument and may mutate it!): (Note that there is no guarantee that the ``char *`` passed to the function remains valid after the call is done. Similarly, if you write -``lib.f(x); lib.f(x)`` where ``x`` is some byte string, the two calls to -``f()`` could sometimes receive different ``char *`` arguments. This is +``lib.f(x); lib.f(x)`` where ``x`` is a variable containing a byte string, +the two calls to ``f()`` could sometimes receive different ``char *`` +pointers, with each of them only valid during the corresponding call. This is important notably for PyPy which uses many optimizations tweaking the data underlying a byte string object. CFFI will not make and free a copy of the whole string at *every* call---it usually won't---but you *cannot* -write code that relies on it: there are cases were that would break.) +write code that relies on it: there are cases were that would break. +If you need a pointer to remain valid, you need to make one explicitly, +for example with ``ptr = ffi.new("char[]", x)``.) You can also pass unicode strings as ``wchar_t *`` or ``char16_t *`` or ``char32_t *`` arguments. Note that |