File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
clang/include/clang/Basic Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff 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
14241427Example:
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
You can’t perform that action at this time.
0 commit comments