Lines Matching refs:hdr
105 data_from_header(struct debug_memory_header *hdr) in data_from_header() argument
107 if (hdr) in data_from_header()
108 return (void *)((char *)hdr + sizeof(struct debug_memory_header)); in data_from_header()
114 footer_from_header(struct debug_memory_header *hdr) in footer_from_header() argument
116 if (hdr) in footer_from_header()
117 …return (struct debug_memory_footer *)((char *)hdr + sizeof(struct debug_memory_header) + hdr->size… in footer_from_header()
127 struct debug_memory_header *hdr; in debug_malloc() local
130 hdr = os_malloc(sizeof(*hdr) + size + sizeof(*ftr)); in debug_malloc()
131 if (!hdr) { in debug_malloc()
138 hdr->no = last_no++; in debug_malloc()
139 hdr->file = file; in debug_malloc()
140 hdr->line = line; in debug_malloc()
141 hdr->function = function; in debug_malloc()
142 hdr->size = size; in debug_malloc()
143 hdr->magic = DEBUG_MEMORY_MAGIC; in debug_malloc()
144 hdr->tag = 0; in debug_malloc()
146 hdr->freed = FALSE; in debug_malloc()
150 debug_backtrace_capture(hdr->backtrace, 0, DEBUG_MEMORY_STACK); in debug_malloc()
153 ftr = footer_from_header(hdr); in debug_malloc()
157 list_addtail(&hdr->head, &list); in debug_malloc()
160 return data_from_header(hdr); in debug_malloc()
167 struct debug_memory_header *hdr; in debug_free() local
173 hdr = header_from_data(ptr); in debug_free()
174 if (hdr->magic != DEBUG_MEMORY_MAGIC) { in debug_free()
182 ftr = footer_from_header(hdr); in debug_free()
185 hdr->file, hdr->line, hdr->function, in debug_free()
192 assert(!hdr->freed); in debug_free()
194 hdr->freed = TRUE; in debug_free()
196 hdr->file = file; in debug_free()
197 hdr->line = line; in debug_free()
199 memset(ptr, DEBUG_FREED_BYTE, hdr->size); in debug_free()
202 list_del(&hdr->head); in debug_free()
204 hdr->magic = 0; in debug_free()
207 os_free(hdr); in debug_free()
309 struct debug_memory_header *hdr; in debug_memory_end() local
313 hdr = LIST_ENTRY(struct debug_memory_header, entry, head); in debug_memory_end()
314 ptr = data_from_header(hdr); in debug_memory_end()
315 ftr = footer_from_header(hdr); in debug_memory_end()
317 if (hdr->magic != DEBUG_MEMORY_MAGIC) { in debug_memory_end()
319 hdr->file, hdr->line, hdr->function, in debug_memory_end()
324 if ((start_no <= hdr->no && hdr->no < last_no) || in debug_memory_end()
325 (last_no < start_no && (hdr->no < last_no || start_no <= hdr->no))) { in debug_memory_end()
327 hdr->file, hdr->line, hdr->function, in debug_memory_end()
328 (unsigned long) hdr->size, ptr); in debug_memory_end()
330 debug_backtrace_dump(hdr->backtrace, DEBUG_MEMORY_STACK); in debug_memory_end()
332 total_size += hdr->size; in debug_memory_end()
337 hdr->file, hdr->line, hdr->function, in debug_memory_end()
360 struct debug_memory_header *hdr; in debug_memory_tag() local
365 hdr = header_from_data(ptr); in debug_memory_tag()
366 if (hdr->magic != DEBUG_MEMORY_MAGIC) { in debug_memory_tag()
371 hdr->tag = tag; in debug_memory_tag()
381 struct debug_memory_header *hdr; in debug_memory_check_block() local
387 hdr = header_from_data(ptr); in debug_memory_check_block()
388 ftr = footer_from_header(hdr); in debug_memory_check_block()
390 if (hdr->magic != DEBUG_MEMORY_MAGIC) { in debug_memory_check_block()
392 hdr->file, hdr->line, hdr->function, ptr); in debug_memory_check_block()
398 hdr->file, hdr->line, hdr->function, ptr); in debug_memory_check_block()
416 struct debug_memory_header *hdr; in debug_memory_check() local
420 hdr = LIST_ENTRY(struct debug_memory_header, entry, head); in debug_memory_check()
421 ftr = footer_from_header(hdr); in debug_memory_check()
422 ptr = (const char *) data_from_header(hdr); in debug_memory_check()
424 if (hdr->magic != DEBUG_MEMORY_MAGIC) { in debug_memory_check()
426 hdr->file, hdr->line, hdr->function, ptr); in debug_memory_check()
432 hdr->file, hdr->line, hdr->function, ptr); in debug_memory_check()
438 if (hdr->freed) { in debug_memory_check()
440 for (i = 0; i < hdr->size; i++) { in debug_memory_check()
443 i, ptr, hdr->size, ptr[i]); in debug_memory_check()
444 debug_printf("Block was freed at %s:%d\n", hdr->file, hdr->line); in debug_memory_check()