Changeset 752 for trunk/server/lib/talloc/talloc.c
- Timestamp:
- Nov 29, 2012, 2:06:31 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 746,748
- Property svn:mergeinfo changed
-
trunk/server/lib/talloc/talloc.c
r745 r752 839 839 if (tc->prev) tc->prev->next = tc->next; 840 840 if (tc->next) tc->next->prev = tc->prev; 841 tc->prev = tc->next = NULL; 841 842 } 842 843 … … 926 927 if (tc->prev) tc->prev->next = tc->next; 927 928 if (tc->next) tc->next->prev = tc->prev; 929 tc->prev = tc->next = NULL; 928 930 } 929 931 … … 1252 1254 if (p) new_parent = TC_PTR_FROM_CHUNK(p); 1253 1255 } 1254 /* finding the parent here is potentially quite1255 expensive, but the alternative, which is to change1256 talloc to always have a valid tc->parent pointer,1257 makes realloc more expensive where there are a1258 large number of children.1259 1260 The reason we need the parent pointer here is that1261 if _talloc_free_internal() fails due to references1262 or a failing destructor we need to re-parent, but1263 the free call can invalidate the prev pointer.1264 */1265 if (new_parent == null_context && (tc->child->refs || tc->child->destructor)) {1266 old_parent = talloc_parent_chunk(ptr);1267 }1268 1256 if (unlikely(_talloc_free_internal(child, location) == -1)) { 1269 1257 if (new_parent == null_context) { 1270 struct talloc_chunk *p = old_parent;1258 struct talloc_chunk *p = talloc_parent_chunk(ptr); 1271 1259 if (p) new_parent = TC_PTR_FROM_CHUNK(p); 1272 1260 } … … 1283 1271 _PUBLIC_ void talloc_free_children(void *ptr) 1284 1272 { 1273 struct talloc_chunk *tc_name = NULL; 1285 1274 struct talloc_chunk *tc; 1286 1275 … … 1291 1280 tc = talloc_chunk_from_ptr(ptr); 1292 1281 1282 /* we do not want to free the context name if it is a child .. */ 1283 if (likely(tc->child)) { 1284 for (tc_name = tc->child; tc_name; tc_name = tc_name->next) { 1285 if (tc->name == TC_PTR_FROM_CHUNK(tc_name)) break; 1286 } 1287 if (tc_name) { 1288 _TLIST_REMOVE(tc->child, tc_name); 1289 if (tc->child) { 1290 tc->child->parent = tc; 1291 } 1292 } 1293 } 1294 1293 1295 _talloc_free_children_internal(tc, ptr, __location__); 1296 1297 /* .. so we put it back after all other children have been freed */ 1298 if (tc_name) { 1299 if (tc->child) { 1300 tc->child->parent = NULL; 1301 } 1302 tc_name->parent = tc; 1303 _TLIST_ADD(tc->child, tc_name); 1304 } 1294 1305 } 1295 1306
Note:
See TracChangeset
for help on using the changeset viewer.