Changeset 746 for vendor/current/lib/talloc/talloc_guide.txt
- Timestamp:
- Nov 27, 2012, 4:56:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified vendor/current/lib/talloc/talloc_guide.txt ¶
r740 r746 27 27 28 28 and the pointer X->name would be a "child" of the talloc context "X" 29 which is itself a child of mem_ctx. So if you do talloc_free(mem_ctx)29 which is itself a child of "mem_ctx". So if you do talloc_free(mem_ctx) 30 30 then it is all destroyed, whereas if you do talloc_free(X) then just X 31 31 and X->name are destroyed, and if you do talloc_free(X->name) then … … 65 65 the underlying "malloc" is), as long as each thread uses different 66 66 memory contexts. 67 If two threads use s the same context then they need to synchronize in67 If two threads use the same context then they need to synchronize in 68 68 order to be safe. In particular: 69 69 - when using talloc_enable_leak_report(), giving directly NULL as a … … 137 137 no modifications and returns -1. 138 138 139 If this pointer has an additional parent when talloc_free() is called 140 then the memory is not actually released, but instead the most 141 recently established parent is destroyed. See talloc_reference() for 142 details on establishing additional parents. 143 144 For more control on which parent is removed, see talloc_unlink() 145 146 talloc_free() operates recursively on its children. 147 148 From the 2.0 version of talloc, as a special case, talloc_free() is 149 refused on pointers that have more than one parent, as talloc would 150 have no way of knowing which parent should be removed. To free a 139 From version 2.0 and onwards, as a special case, talloc_free() is 140 refused on pointers that have more than one parent associated, as talloc 141 would have no way of knowing which parent should be removed. This is 142 different from older versions in the sense that always the reference to 143 the most recently established parent has been destroyed. Hence to free a 151 144 pointer that has more than one parent please use talloc_unlink(). 152 145 … … 163 156 functions. 164 157 165 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 166 int talloc_free_children(void *ptr); 158 talloc_free() operates recursively on its children. 159 160 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 161 void talloc_free_children(void *ptr); 167 162 168 163 The talloc_free_children() walks along the list of all children of a … … 170 165 itself. 171 166 167 A NULL argument is handled as no-op. 172 168 173 169 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- … … 191 187 cause this pointer to be freed if it runs out of parents. 192 188 193 - you can talloc_free() the pointer itself . That will destroy the194 most recently established parent to the pointer and leave the195 pointer as a child of its current parent.189 - you can talloc_free() the pointer itself if it has at maximum one 190 parent. This behaviour has been changed since the release of version 191 2.0. Further informations in the description of "talloc_free". 196 192 197 193 For more control on which parent to remove, see talloc_unlink() … … 209 205 is NULL, then the function will make no modifications and return -1. 210 206 211 Usually you can just use talloc_free() instead of talloc_unlink(), but 212 sometimes it is useful to have the additional control on which parent 213 is removed. 214 207 You can just use talloc_free() instead of talloc_unlink() if there 208 is at maximum one parent. This behaviour has been changed since the 209 release of version 2.0. Further informations in the description of 210 "talloc_free". 215 211 216 212 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- … … 484 480 485 481 This provides a more detailed report than talloc_report(). It will 486 recursively print the en sire tree of memory referenced by the482 recursively print the entire tree of memory referenced by the 487 483 pointer. References in the tree are shown by giving the name of the 488 484 pointer that is referenced. … … 643 639 The talloc_asprintf_append() function appends the given formatted 644 640 string to the given string. 645 Use this vari ent when the string in the current talloc buffer may641 Use this variant when the string in the current talloc buffer may 646 642 have been truncated in length. 647 643 … … 657 653 The talloc_asprintf_append() function appends the given formatted 658 654 string to the end of the currently allocated talloc buffer. 659 Use this vari ent when the string in the current talloc buffer has655 Use this variant when the string in the current talloc buffer has 660 656 not been changed. 661 657 … … 731 727 talloc_set_type(const void *ptr, type); 732 728 733 This macro allows you to force the name of a pointer to be a729 This macro allows you to force the name of a pointer to be of a 734 730 particular type. This can be used in conjunction with 735 731 talloc_get_type() to do type checking on void* pointers. … … 742 738 talloc_get_size(const void *ctx); 743 739 744 This function lets you know the amount of memory alloc ed so far by740 This function lets you know the amount of memory allocated so far by 745 741 this context. It does NOT account for subcontext memory. 746 742 This can be used to calculate the size of an array. … … 769 765 void talloc_set_log_stderr(void) 770 766 771 This sets the talloc log function to write log messages to stderr 767 This sets the talloc log function to write log messages to stderr.
Note:
See TracChangeset
for help on using the changeset viewer.