Skip to content

Commit 00c2349

Browse files
SzelethusNagyDonatsteakhal
authored
Apply suggestions from code review
Co-authored-by: Donát Nagy <[email protected]> Co-authored-by: Balazs Benics <[email protected]>
1 parent 24b1511 commit 00c2349

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,16 +1416,19 @@ be found.
14161416
parameters: the allocation type, and the index of the parameter that is being
14171417
deallocated (counting from 1).
14181418
* Use ``ownership_holds`` to mark that a function takes over the ownership of a
1419-
piece of memory. The analyzer will assume that the memory is not leaked even
1420-
if it finds that the last pointer referencing it went out of scope (almost as
1421-
if it was freed). Takes 2 parameters: the allocation type, and the index of
1422-
the parameter whose ownership will be taken over (counting from 1).
1419+
piece of memory and will free it at some unspecified point in the future. Like
1420+
``ownership_takes``, this takes 2 parameters: the allocation type, and the
1421+
index of the parameter whose ownership will be taken over (counting from 1).
1422+
The annotations ``ownership_takes`` and ``ownership_holds`` both prevent memory
1423+
leak reports (concerning the specified argument); the difference between them
1424+
is that using taken memory is a use-after-free error, while using held memory
1425+
is assumed to be legitimate.
14231426

14241427
Example:
14251428

14261429
.. code-block:: c
14271430

1428-
// Denotes that my_malloc will return with adynamically allocated piece of
1431+
// Denotes that my_malloc will return with a dynamically allocated piece of
14291432
// memory using malloc().
14301433
void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
14311434

0 commit comments

Comments
 (0)