summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2017-08-31 17:44:08 +0200
committerArmin Rigo <arigo@tunes.org>2017-08-31 17:44:08 +0200
commit5fdec43a181a5d6bb395f011c481b0e99747a7b7 (patch)
tree7ef095ac35defd02dd1b7c2a895c8f7d80f522d9 /doc
parentc98e80c3ec2bbd09815b0aa45d6a5687b65ece7e (diff)
downloadcffi-5fdec43a181a5d6bb395f011c481b0e99747a7b7.tar.gz
Write down an explicit example of what not to do
Diffstat (limited to 'doc')
-rw-r--r--doc/source/ref.rst3
1 files changed, 3 insertions, 0 deletions
diff --git a/doc/source/ref.rst b/doc/source/ref.rst
index 7c42aaa..fd64536 100644
--- a/doc/source/ref.rst
+++ b/doc/source/ref.rst
@@ -51,6 +51,9 @@ the value of type ``cdecl`` that it points to. This means that the raw
data can be used as long as this object is kept alive, but must not be
used for a longer time. Be careful about that when copying the
pointer to the memory somewhere else, e.g. into another structure.
+Also, this means that a line like ``x = ffi.new(...)[0]`` is *always
+wrong:* the newly allocated object goes out of scope instantly, and so
+is freed immediately, and ``x`` is garbage.
The returned memory is initially cleared (filled with zeroes), before
the optional initializer is applied. For performance, see