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