* pointer.
*/
is_child = talloc_is_parent(tc->refs, ptr);
- _talloc_free(tc->refs);
if (is_child) {
+ _talloc_free(tc->refs);
return _talloc_free(ptr);
+ } else {
+ /* the first reference becomes the owner */
+ _talloc_steal(talloc_parent(tc->refs), ptr);
+ _talloc_free(tc->refs);
}
return -1;
}
return NULL;
}
+ /* don't let anybody try to realloc a talloc_pool */
+ if (unlikely(tc->flags & TALLOC_FLAG_POOL)) {
+ return NULL;
+ }
+
/* don't shrink if we have less than 1k to gain */
if ((size < tc->size) && ((tc->size - size) < 1024)) {
tc->size = size;