Lines Matching refs:hdr

95 static void debug_header( memory_header *hdr )  in debug_header()  argument
103 (size_t) hdr, (size_t) hdr->prev, (size_t) hdr->next, in debug_header()
104 hdr->alloc, hdr->size ); in debug_header()
106 (size_t) hdr->prev_free, (size_t) hdr->next_free ); in debug_header()
110 for( i = 0; i < hdr->trace_count; i++ ) in debug_header()
111 mbedtls_fprintf( stderr, "%s\n", hdr->trace[i] ); in debug_header()
138 static int verify_header( memory_header *hdr ) in verify_header() argument
140 if( hdr->magic1 != MAGIC1 ) in verify_header()
148 if( hdr->magic2 != MAGIC2 ) in verify_header()
156 if( hdr->alloc > 1 ) in verify_header()
164 if( hdr->prev != NULL && hdr->prev == hdr->next ) in verify_header()
172 if( hdr->prev_free != NULL && hdr->prev_free == hdr->next_free ) in verify_header()
383 memory_header *hdr, *old = NULL; in buffer_alloc_free() local
399 hdr = (memory_header *) p; in buffer_alloc_free()
401 if( verify_header( hdr ) != 0 ) in buffer_alloc_free()
404 if( hdr->alloc != 1 ) in buffer_alloc_free()
413 hdr->alloc = 0; in buffer_alloc_free()
417 heap.total_used -= hdr->size; in buffer_alloc_free()
421 free( hdr->trace ); in buffer_alloc_free()
422 hdr->trace = NULL; in buffer_alloc_free()
423 hdr->trace_count = 0; in buffer_alloc_free()
428 if( hdr->prev != NULL && hdr->prev->alloc == 0 ) in buffer_alloc_free()
433 hdr->prev->size += sizeof(memory_header) + hdr->size; in buffer_alloc_free()
434 hdr->prev->next = hdr->next; in buffer_alloc_free()
435 old = hdr; in buffer_alloc_free()
436 hdr = hdr->prev; in buffer_alloc_free()
438 if( hdr->next != NULL ) in buffer_alloc_free()
439 hdr->next->prev = hdr; in buffer_alloc_free()
446 if( hdr->next != NULL && hdr->next->alloc == 0 ) in buffer_alloc_free()
451 hdr->size += sizeof(memory_header) + hdr->next->size; in buffer_alloc_free()
452 old = hdr->next; in buffer_alloc_free()
453 hdr->next = hdr->next->next; in buffer_alloc_free()
455 if( hdr->prev_free != NULL || hdr->next_free != NULL ) in buffer_alloc_free()
457 if( hdr->prev_free != NULL ) in buffer_alloc_free()
458 hdr->prev_free->next_free = hdr->next_free; in buffer_alloc_free()
460 heap.first_free = hdr->next_free; in buffer_alloc_free()
462 if( hdr->next_free != NULL ) in buffer_alloc_free()
463 hdr->next_free->prev_free = hdr->prev_free; in buffer_alloc_free()
466 hdr->prev_free = old->prev_free; in buffer_alloc_free()
467 hdr->next_free = old->next_free; in buffer_alloc_free()
469 if( hdr->prev_free != NULL ) in buffer_alloc_free()
470 hdr->prev_free->next_free = hdr; in buffer_alloc_free()
472 heap.first_free = hdr; in buffer_alloc_free()
474 if( hdr->next_free != NULL ) in buffer_alloc_free()
475 hdr->next_free->prev_free = hdr; in buffer_alloc_free()
477 if( hdr->next != NULL ) in buffer_alloc_free()
478 hdr->next->prev = hdr; in buffer_alloc_free()
488 hdr->next_free = heap.first_free; in buffer_alloc_free()
490 heap.first_free->prev_free = hdr; in buffer_alloc_free()
491 heap.first_free = hdr; in buffer_alloc_free()