Lines Matching refs:tc

108 #define TC_PTR_FROM_CHUNK(tc) ((void *)(TC_HDR_SIZE + (char*)tc))  argument
114 struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); in talloc_chunk_from_ptr() local
115 if ((tc->flags & ~0xF) != TALLOC_MAGIC) { in talloc_chunk_from_ptr()
118 if (tc->flags & TALLOC_FLAG_FREE) { in talloc_chunk_from_ptr()
121 return tc; in talloc_chunk_from_ptr()
157 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); in talloc_parent_chunk() local
158 while (tc->prev) tc=tc->prev; in talloc_parent_chunk()
159 return tc->parent; in talloc_parent_chunk()
164 struct talloc_chunk *tc = talloc_parent_chunk(ptr); in talloc_parent() local
165 return tc? TC_PTR_FROM_CHUNK(tc) : NULL; in talloc_parent()
173 struct talloc_chunk *tc; in _talloc() local
183 tc = malloc(TC_HDR_SIZE+size); in _talloc()
184 if (tc == NULL) return NULL; in _talloc()
186 tc->size = size; in _talloc()
187 tc->flags = TALLOC_MAGIC; in _talloc()
188 tc->destructor = NULL; in _talloc()
189 tc->child = NULL; in _talloc()
190 tc->name = NULL; in _talloc()
191 tc->refs = NULL; in _talloc()
192 tc->null_refs = 0; in _talloc()
197 tc->parent = parent; in _talloc()
203 _TLIST_ADD(parent->child, tc); in _talloc()
205 tc->next = tc->prev = tc->parent = NULL; in _talloc()
208 return TC_PTR_FROM_CHUNK(tc); in _talloc()
220 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); in talloc_set_destructor() local
221 tc->destructor = destructor; in talloc_set_destructor()
229 struct talloc_chunk *tc; in talloc_increase_ref_count() local
232 tc = talloc_chunk_from_ptr(ptr); in talloc_increase_ref_count()
233 tc->null_refs++; in talloc_increase_ref_count()
263 struct talloc_chunk *tc; in talloc_reference() local
267 tc = talloc_chunk_from_ptr(ptr); in talloc_reference()
277 _TLIST_ADD(tc->refs, handle); in talloc_reference()
288 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); in talloc_unreference() local
295 if ((context == null_context) && tc->null_refs) { in talloc_unreference()
296 tc->null_refs--; in talloc_unreference()
300 for (h=tc->refs;h;h=h->next) { in talloc_unreference()
313 _TLIST_REMOVE(tc->refs, h); in talloc_unreference()
378 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); in talloc_set_name_v() local
379 tc->name = talloc_vasprintf(ptr, fmt, ap); in talloc_set_name_v()
380 if (tc->name) { in talloc_set_name_v()
381 talloc_set_name_const(tc->name, ".name"); in talloc_set_name_v()
402 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); in talloc_set_name_const() local
403 tc->name = name; in talloc_set_name_const()
450 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); in talloc_get_name() local
451 if (tc->name == TALLOC_MAGIC_REFERENCE) { in talloc_get_name()
454 if (tc->name) { in talloc_get_name()
455 return tc->name; in talloc_get_name()
504 struct talloc_chunk *tc; in talloc_free_children() local
510 tc = talloc_chunk_from_ptr(ptr); in talloc_free_children()
512 while (tc->child) { in talloc_free_children()
518 void *child = TC_PTR_FROM_CHUNK(tc->child); in talloc_free_children()
520 if (tc->child->refs) { in talloc_free_children()
521 struct talloc_chunk *p = talloc_parent_chunk(tc->child->refs); in talloc_free_children()
544 struct talloc_chunk *tc; in talloc_free() local
550 tc = talloc_chunk_from_ptr(ptr); in talloc_free()
552 if (tc->null_refs) { in talloc_free()
553 tc->null_refs--; in talloc_free()
557 if (tc->refs) { in talloc_free()
558 talloc_reference_destructor(tc->refs); in talloc_free()
562 if (tc->flags & TALLOC_FLAG_LOOP) { in talloc_free()
567 if (tc->destructor) { in talloc_free()
568 talloc_destructor_t d = tc->destructor; in talloc_free()
572 tc->destructor = (talloc_destructor_t)-1; in talloc_free()
574 tc->destructor = d; in talloc_free()
577 tc->destructor = NULL; in talloc_free()
580 tc->flags |= TALLOC_FLAG_LOOP; in talloc_free()
584 if (tc->parent) { in talloc_free()
585 _TLIST_REMOVE(tc->parent->child, tc); in talloc_free()
586 if (tc->parent->child) { in talloc_free()
587 tc->parent->child->parent = tc->parent; in talloc_free()
590 if (tc->prev) tc->prev->next = tc->next; in talloc_free()
591 if (tc->next) tc->next->prev = tc->prev; in talloc_free()
594 tc->flags |= TALLOC_FLAG_FREE; in talloc_free()
596 free(tc); in talloc_free()
608 struct talloc_chunk *tc; in _talloc_realloc() local
626 tc = talloc_chunk_from_ptr(ptr); in _talloc_realloc()
629 if (tc->refs) { in _talloc_realloc()
634 tc->flags |= TALLOC_FLAG_FREE; in _talloc_realloc()
639 memcpy(new_ptr, tc, tc->size + TC_HDR_SIZE); in _talloc_realloc()
640 free(tc); in _talloc_realloc()
643 new_ptr = realloc(tc, size + TC_HDR_SIZE); in _talloc_realloc()
646 tc->flags &= ~TALLOC_FLAG_FREE; in _talloc_realloc()
650 tc = new_ptr; in _talloc_realloc()
651 tc->flags &= ~TALLOC_FLAG_FREE; in _talloc_realloc()
652 if (tc->parent) { in _talloc_realloc()
653 tc->parent->child = new_ptr; in _talloc_realloc()
655 if (tc->child) { in _talloc_realloc()
656 tc->child->parent = new_ptr; in _talloc_realloc()
659 if (tc->prev) { in _talloc_realloc()
660 tc->prev->next = tc; in _talloc_realloc()
662 if (tc->next) { in _talloc_realloc()
663 tc->next->prev = tc; in _talloc_realloc()
666 tc->size = size; in _talloc_realloc()
667 talloc_set_name_const(TC_PTR_FROM_CHUNK(tc), name); in _talloc_realloc()
669 return TC_PTR_FROM_CHUNK(tc); in _talloc_realloc()
679 struct talloc_chunk *tc, *new_tc; in talloc_steal() local
689 tc = talloc_chunk_from_ptr(ptr); in talloc_steal()
692 if (tc->parent) { in talloc_steal()
693 _TLIST_REMOVE(tc->parent->child, tc); in talloc_steal()
694 if (tc->parent->child) { in talloc_steal()
695 tc->parent->child->parent = tc->parent; in talloc_steal()
698 if (tc->prev) tc->prev->next = tc->next; in talloc_steal()
699 if (tc->next) tc->next->prev = tc->prev; in talloc_steal()
702 tc->parent = tc->next = tc->prev = NULL; in talloc_steal()
708 if (tc == new_tc) { in talloc_steal()
712 if (tc->parent) { in talloc_steal()
713 _TLIST_REMOVE(tc->parent->child, tc); in talloc_steal()
714 if (tc->parent->child) { in talloc_steal()
715 tc->parent->child->parent = tc->parent; in talloc_steal()
718 if (tc->prev) tc->prev->next = tc->next; in talloc_steal()
719 if (tc->next) tc->next->prev = tc->prev; in talloc_steal()
722 tc->parent = new_tc; in talloc_steal()
724 _TLIST_ADD(new_tc->child, tc); in talloc_steal()
735 struct talloc_chunk *c, *tc; in talloc_total_size() local
744 tc = talloc_chunk_from_ptr(ptr); in talloc_total_size()
746 if (tc->flags & TALLOC_FLAG_LOOP) { in talloc_total_size()
750 tc->flags |= TALLOC_FLAG_LOOP; in talloc_total_size()
752 total = tc->size; in talloc_total_size()
753 for (c=tc->child;c;c=c->next) { in talloc_total_size()
757 tc->flags &= ~TALLOC_FLAG_LOOP; in talloc_total_size()
768 struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr); in talloc_total_blocks() local
770 if (tc->flags & TALLOC_FLAG_LOOP) { in talloc_total_blocks()
774 tc->flags |= TALLOC_FLAG_LOOP; in talloc_total_blocks()
777 for (c=tc->child;c;c=c->next) { in talloc_total_blocks()
781 tc->flags &= ~TALLOC_FLAG_LOOP; in talloc_total_blocks()
791 struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); in talloc_reference_count() local
795 for (h=tc->refs;h;h=h->next) { in talloc_reference_count()
806 struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr); in talloc_report_depth() local
808 if (tc->flags & TALLOC_FLAG_LOOP) { in talloc_report_depth()
812 tc->flags |= TALLOC_FLAG_LOOP; in talloc_report_depth()
814 for (c=tc->child;c;c=c->next) { in talloc_report_depth()
830 tc->flags &= ~TALLOC_FLAG_LOOP; in talloc_report_depth()
857 struct talloc_chunk *c, *tc; in talloc_report() local
869 tc = talloc_chunk_from_ptr(ptr); in talloc_report()
871 for (c=tc->child;c;c=c->next) { in talloc_report()
918 struct talloc_chunk *c, *tc = talloc_chunk_from_ptr(ptr); in talloc_report_depth_str() local
920 if (tc->flags & TALLOC_FLAG_LOOP) { in talloc_report_depth_str()
924 tc->flags |= TALLOC_FLAG_LOOP; in talloc_report_depth_str()
926 for (c=tc->child;c;c=c->next) { in talloc_report_depth_str()
948 tc->flags &= ~TALLOC_FLAG_LOOP; in talloc_report_depth_str()
1147 struct talloc_chunk *tc; in talloc_vasprintf_append() local
1155 tc = talloc_chunk_from_ptr(s); in talloc_vasprintf_append()
1159 s_len = tc->size - 1; in talloc_vasprintf_append()
1265 struct talloc_chunk *tc; in talloc_get_size() local
1270 tc = talloc_chunk_from_ptr(context); in talloc_get_size()
1272 return tc->size; in talloc_get_size()
1280 struct talloc_chunk *tc; in talloc_find_parent_byname() local
1286 tc = talloc_chunk_from_ptr(context); in talloc_find_parent_byname()
1287 while (tc) { in talloc_find_parent_byname()
1288 if (tc->name && strcmp(tc->name, name) == 0) { in talloc_find_parent_byname()
1289 return TC_PTR_FROM_CHUNK(tc); in talloc_find_parent_byname()
1291 while (tc && tc->prev) tc = tc->prev; in talloc_find_parent_byname()
1292 tc = tc->parent; in talloc_find_parent_byname()
1302 struct talloc_chunk *tc; in talloc_show_parents() local
1309 tc = talloc_chunk_from_ptr(context); in talloc_show_parents()
1311 while (tc) { in talloc_show_parents()
1312 fprintf(file, "\t'%s'\n", talloc_get_name(TC_PTR_FROM_CHUNK(tc))); in talloc_show_parents()
1313 while (tc && tc->prev) tc = tc->prev; in talloc_show_parents()
1314 tc = tc->parent; in talloc_show_parents()