• Home
  • Raw
  • Download

Lines Matching refs:header

28 #define END_MAGIC(header) ((unsigned)((const hieralloc_header_t *)header + 1) % 0x10000 | 0x1337000…  argument
41 static inline int check_header(const hieralloc_header_t * header) in check_header() argument
43 if (BEGIN_MAGIC() != header->beginMagic) in check_header()
44 printf("*** hieralloc check_header fail: %p ***\n", header + 1); in check_header()
45 assert(BEGIN_MAGIC() == header->beginMagic); in check_header()
46 if (&hieralloc_global_header == header) in check_header()
48 assert(0x13370000 == header->endMagic); in check_header()
51 assert(END_MAGIC(header) == header->endMagic); in check_header()
52 assert(!header->nextSibling || header->nextSibling->prevSibling == header); in check_header()
53 assert(!header->nextSibling || header->nextSibling->parent == header->parent); in check_header()
54 assert(!header->prevSibling || header->prevSibling->nextSibling == header); in check_header()
55 assert(!header->prevSibling || header->prevSibling->parent == header->parent); in check_header()
61 hieralloc_header_t * header = (hieralloc_header_t *)(ptr) - 1; in get_header() local
62 check_header(header); in get_header()
63 return header; in get_header()
66 static void check_children(hieralloc_header_t * header) in check_children() argument
68 check_header(header); in check_children()
70 hieralloc_header_t * child = header->child; in check_children()
77 assert(childCount == header->childCount); in check_children()
82 static void add_to_parent(hieralloc_header_t * parent, hieralloc_header_t * header) in add_to_parent() argument
84 assert(NULL == header->parent); in add_to_parent()
85 assert(NULL == header->prevSibling); in add_to_parent()
86 assert(NULL == header->nextSibling); in add_to_parent()
96 parent->child->prevSibling = header; in add_to_parent()
98 header->nextSibling = parent->child; in add_to_parent()
99 header->prevSibling = NULL; in add_to_parent()
100 header->parent = parent; in add_to_parent()
101 parent->child = header; in add_to_parent()
104 assert(!header->nextSibling || header->nextSibling->prevSibling == header); in add_to_parent()
105 assert(!header->nextSibling || header->nextSibling->parent == header->parent); in add_to_parent()
106 assert(!header->prevSibling || header->prevSibling->nextSibling == header); in add_to_parent()
107 assert(!header->prevSibling || header->prevSibling->parent == header->parent); in add_to_parent()
111 static void remove_from_parent(hieralloc_header_t * header) in remove_from_parent() argument
113 hieralloc_header_t * parent = header->parent; in remove_from_parent()
114 hieralloc_header_t * sibling = header->prevSibling; in remove_from_parent()
115 assert(!header->nextSibling || header->nextSibling->prevSibling == header); in remove_from_parent()
116 assert(!header->nextSibling || header->nextSibling->parent == header->parent); in remove_from_parent()
117 assert(!header->prevSibling || header->prevSibling->nextSibling == header); in remove_from_parent()
118 assert(!header->prevSibling || header->prevSibling->parent == header->parent); in remove_from_parent()
121 if (sibling->nextSibling != header) in remove_from_parent()
123 printf("&sibling->nextSibling=%p &header=%p \n", &sibling->nextSibling, &header); in remove_from_parent()
124 printf("sibling->nextSibling=%p header=%p \n", sibling->nextSibling, header); in remove_from_parent()
126 sibling->nextSibling = header->nextSibling; in remove_from_parent()
127 if (header->nextSibling) in remove_from_parent()
128 header->nextSibling->prevSibling = sibling; in remove_from_parent()
129 header->prevSibling = NULL; in remove_from_parent()
130 header->nextSibling = NULL; in remove_from_parent()
134 assert(parent->child == header); in remove_from_parent()
135 parent->child = header->nextSibling; in remove_from_parent()
136 if (header->nextSibling) in remove_from_parent()
137 header->nextSibling->prevSibling = NULL; in remove_from_parent()
138 header->nextSibling = NULL; in remove_from_parent()
140 header->parent = NULL; in remove_from_parent()
183 hieralloc_header_t * header = get_header(ptr); in hieralloc_reallocate() local
184 hieralloc_header_t * parent = header->parent; in hieralloc_reallocate()
188 remove_from_parent(header); in hieralloc_reallocate()
190 add_to_parent(parent, header); in hieralloc_reallocate()
193 header = (hieralloc_header_t *)realloc(header, size + sizeof(hieralloc_header_t)); in hieralloc_reallocate()
194 assert(header); in hieralloc_reallocate()
195 header->size = size; in hieralloc_reallocate()
196 header->name = name; in hieralloc_reallocate()
197 if (ptr == (header + 1)) in hieralloc_reallocate()
200 header->beginMagic = BEGIN_MAGIC(); in hieralloc_reallocate()
201 header->endMagic = END_MAGIC(header); in hieralloc_reallocate()
202 if (header->nextSibling) in hieralloc_reallocate()
203 header->nextSibling->prevSibling = header; in hieralloc_reallocate()
204 if (header->prevSibling) in hieralloc_reallocate()
205 header->prevSibling->nextSibling = header; in hieralloc_reallocate()
207 parent->child = header; in hieralloc_reallocate()
209 hieralloc_header_t * child = header->child; in hieralloc_reallocate()
212 child->parent = header; in hieralloc_reallocate()
217 assert(allocations.find(header + 1) == allocations.end()); in hieralloc_reallocate()
218 allocations.insert(header + 1); in hieralloc_reallocate()
220 return header + 1; in hieralloc_reallocate()
230 hieralloc_header_t * header = get_header(ptr); in hieralloc_free() local
232 header->refCount--; in hieralloc_free()
233 if (header->refCount > 0) in hieralloc_free()
236 if (header->destructor) in hieralloc_free()
237 if (header->destructor(ptr)) in hieralloc_free()
243 hieralloc_header_t * child = header->child; in hieralloc_free()
253 add_to_parent(header->parent, current); in hieralloc_free()
262 assert(0 == header->childCount); in hieralloc_free()
263 assert(!header->child); in hieralloc_free()
264 remove_from_parent(header); in hieralloc_free()
265 memset(header, 0xfe, header->size + sizeof(*header)); in hieralloc_free()
271 free(header); in hieralloc_free()
296 hieralloc_header_t * header = get_header(ptr); in hieralloc_steal() local
297 remove_from_parent(header); in hieralloc_steal()
298 add_to_parent(get_header(new_ctx), header); in hieralloc_steal()
323 const hieralloc_header_t * header = get_header(ptr); in hieralloc_parent() local
324 return header->parent + 1; in hieralloc_parent()
366 hieralloc_header_t * header = get_header(str); in _hieralloc_strlendup_append() local
367 …char * ret = (char *)hieralloc_reallocate(header->parent + 1, str, sizeof(char) * (len + appendLen… in _hieralloc_strlendup_append()
471 static void _hieralloc_report(const hieralloc_header_t * header, FILE * file, unsigned tab) in _hieralloc_report() argument
476 check_header(header); in _hieralloc_report()
477 fprintf(file, "%p: child=%d ref=%d size=%d dctor=%p name='%.256s' \n", header + 1, in _hieralloc_report()
478 header->childCount, header->refCount, header->size, header->destructor, header->name); in _hieralloc_report()
479 const hieralloc_header_t * child = header->child; in _hieralloc_report()
497 static void _hieralloc_report_brief(const hieralloc_header_t * header, FILE * file, unsigned * data) in _hieralloc_report_brief() argument
499 check_header(header); in _hieralloc_report_brief()
501 data[1] += header->size; in _hieralloc_report_brief()
502 data[2] += header->childCount; in _hieralloc_report_brief()
503 data[3] += header->refCount; in _hieralloc_report_brief()
504 const hieralloc_header_t * child = header->child; in _hieralloc_report_brief()
524 const hieralloc_header_t * header = get_header(ptr); in hieralloc_report_lineage() local
525 if (header->parent) in hieralloc_report_lineage()
526 hieralloc_report_lineage(header->parent + 1, file, tab + 2); in hieralloc_report_lineage()
530 …ptr, header->size, header->childCount, header->refCount, header->name, header->parent ? header->pa… in hieralloc_report_lineage()